-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide way to set cluster consistency (#8)
* Provide way to set cluster consistency rdar://102086631 * Run swiftformat * Change swiftformat rule to put access control keyword on declaration rather than extension * Clean up configuration init * Document default consistency levels
- Loading branch information
Showing
11 changed files
with
226 additions
and
238 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 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,59 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift Cassandra Client open source project | ||
// | ||
// Copyright (c) 2022 Apple Inc. and the Swift Cassandra Client project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See CONTRIBUTORS.txt for the list of Swift Cassandra Client project authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
@_implementationOnly import CDataStaxDriver | ||
|
||
extension CassandraClient { | ||
/// Consistency levels | ||
public enum Consistency { | ||
case any | ||
case one | ||
case two | ||
case three | ||
case quorum | ||
case all | ||
case localQuorum | ||
case eachQuorum | ||
case serial | ||
case localSerial | ||
case localOne | ||
|
||
var cassConsistency: CassConsistency { | ||
switch self { | ||
case .any: | ||
return CASS_CONSISTENCY_ANY | ||
case .one: | ||
return CASS_CONSISTENCY_ONE | ||
case .two: | ||
return CASS_CONSISTENCY_TWO | ||
case .three: | ||
return CASS_CONSISTENCY_THREE | ||
case .quorum: | ||
return CASS_CONSISTENCY_QUORUM | ||
case .all: | ||
return CASS_CONSISTENCY_ALL | ||
case .localQuorum: | ||
return CASS_CONSISTENCY_LOCAL_QUORUM | ||
case .eachQuorum: | ||
return CASS_CONSISTENCY_EACH_QUORUM | ||
case .serial: | ||
return CASS_CONSISTENCY_SERIAL | ||
case .localSerial: | ||
return CASS_CONSISTENCY_LOCAL_SERIAL | ||
case .localOne: | ||
return CASS_CONSISTENCY_LOCAL_ONE | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.