File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
Tests/CassandraClientTests Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,10 @@ extension CassandraClient {
8181 if let consistency = options. consistency {
8282 try checkResult { cass_statement_set_consistency ( self . rawPointer, consistency. cassConsistency) }
8383 }
84+
85+ if let requestTimeout = options. requestTimeout {
86+ try checkResult { cass_statement_set_request_timeout ( self . rawPointer, requestTimeout) }
87+ }
8488 }
8589
8690 func setPagingSize( _ pagingSize: Int32 ) throws {
@@ -118,13 +122,21 @@ extension CassandraClient {
118122 public struct Options : CustomStringConvertible {
119123 /// Sets the statement's consistency level. Default is `.localOne`.
120124 public var consistency : CassandraClient . Consistency ?
125+ /// Sets the statement's request timeout in milliseconds. Default is `CASS_UINT64_MAX`
126+ public var requestTimeout : UInt64 ?
121127
122- public init ( consistency: CassandraClient . Consistency ? = . none ) {
128+ public init ( consistency: CassandraClient . Consistency ? = nil , requestTimeout : UInt64 ? = nil ) {
123129 self . consistency = consistency
130+ self . requestTimeout = requestTimeout
124131 }
125132
126133 public var description : String {
127- " Options { consistency: \( String ( describing: self . consistency) ) } "
134+ """
135+ Options {
136+ consistency: \( String ( describing: self . consistency) ) ,
137+ requestTimeout: \( String ( describing: self . requestTimeout) )
138+ }
139+ """
128140 }
129141 }
130142 }
Original file line number Diff line number Diff line change @@ -194,8 +194,7 @@ final class Tests: XCTestCase {
194194 let tableName = " test_ \( DispatchTime . now ( ) . uptimeNanoseconds) "
195195 XCTAssertNoThrow ( try self . cassandraClient. run ( " create table \( tableName) (id int primary key, data text); " ) . wait ( ) )
196196
197- var options = CassandraClient . Statement. Options ( )
198- options. consistency = . localQuorum
197+ let options = CassandraClient . Statement. Options ( consistency: . localQuorum)
199198
200199 let count = Int . random ( in: 5000 ... 6000 )
201200 var futures = [ EventLoopFuture < Void > ] ( )
You can’t perform that action at this time.
0 commit comments