-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9c1cb5
commit 2f95fc9
Showing
19 changed files
with
263 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2021 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package common | ||
|
||
// ConsistentLevelType is the level of redo log consistent level. | ||
type ConsistentLevelType string | ||
|
||
const ( | ||
// ConsistentLevelNone no consistent guarantee. | ||
ConsistentLevelNone ConsistentLevelType = "none" | ||
// ConsistentLevelEventual eventual consistent. | ||
ConsistentLevelEventual ConsistentLevelType = "eventual" | ||
) | ||
|
||
type ConsistentStorage string | ||
|
||
const ( | ||
ConsistentStorageBlackhole ConsistentStorage = "blackhole" | ||
ConsistentStorageLocal ConsistentStorage = "local" | ||
ConsistentStorageNFS ConsistentStorage = "nfs" | ||
ConsistentStorageS3 ConsistentStorage = "s3" | ||
ConsistentStorageGCS ConsistentStorage = "gcs" | ||
) | ||
|
||
// IsValidConsistentLevel checks whether a given consistent level is valid | ||
func IsValidConsistentLevel(level string) bool { | ||
switch ConsistentLevelType(level) { | ||
case ConsistentLevelNone, ConsistentLevelEventual: | ||
return true | ||
default: | ||
return false | ||
} | ||
} | ||
|
||
// IsConsistentEnabled returns whether the consistent feature is enabled. | ||
func IsConsistentEnabled(level string) bool { | ||
return IsValidConsistentLevel(level) && ConsistentLevelType(level) != ConsistentLevelNone | ||
} | ||
|
||
// IsValidConsistentStorage checks whether a give consistent storage is valid. | ||
func IsValidConsistentStorage(scheme string) bool { | ||
switch ConsistentStorage(scheme) { | ||
case ConsistentStorageBlackhole, | ||
ConsistentStorageLocal, ConsistentStorageNFS, | ||
ConsistentStorageS3, ConsistentStorageGCS: | ||
return true | ||
default: | ||
return false | ||
} | ||
} | ||
|
||
// IsExternalStorage returns whether external storage, such as s3 and gcs, is used. | ||
func IsExternalStorage(storage string) bool { | ||
switch ConsistentStorage(storage) { | ||
case ConsistentStorageS3, ConsistentStorageGCS: | ||
return true | ||
default: | ||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.