Explorar o código

Remove timeout argument from Client makeCall method (dthurn@)

Tim Burks %!s(int64=9) %!d(string=hai) anos
pai
achega
09aaf5aafd

+ 2 - 6
Examples/Echo/Swift/Echo/EchoViewController.swift

@@ -112,9 +112,7 @@ class EchoViewController : NSViewController, NSTextFieldDelegate {
         guard let client = client else {
           return
         }
-        call = client.makeCall(host: requestHost,
-                               method: "/echo.Echo/Get",
-                               timeout: 30.0)
+        call = client.makeCall(host: requestHost, method: "/echo.Echo/Get")
         guard let call = call else {
           return
         }
@@ -145,9 +143,7 @@ class EchoViewController : NSViewController, NSTextFieldDelegate {
         guard let client = client else {
           return
         }
-        call = client.makeCall(host: requestHost,
-                               method: "/echo.Echo/Update",
-                               timeout: 30.0)
+        call = client.makeCall(host: requestHost, method: "/echo.Echo/Update")
         guard let call = call else {
           return
         }

+ 1 - 1
Examples/Sessions/Sessions/Document.swift

@@ -165,7 +165,7 @@ class Document: NSDocument {
           break
         }
         let method = (i < steps) ? "/hello" : "/quit"
-        let call = self.client.makeCall(host: host, method: method, timeout: 30)
+        let call = self.client.makeCall(host: host, method: method)
 
         let metadata = Metadata([["x": "xylophone"],
                                  ["y": "yu"],

+ 1 - 2
Examples/Speech/Speech/SpeechRecognitionService.swift

@@ -42,8 +42,7 @@ class SpeechRecognitionService {
       if (!nowStreaming) {
         // if we aren't already streaming, set up a gRPC connection
         call = client.makeCall(host: HOST,
-                               method: "/google.cloud.speech.v1beta1.Speech/StreamingRecognize",
-                               timeout: 120.0)
+                               method: "/google.cloud.speech.v1beta1.Speech/StreamingRecognize")
 
         if let call = call {
           let metadata = Metadata(["x-goog-api-key":API_KEY,

+ 1 - 1
Examples/StickyNotes/StickyNotes/StickyNoteViewController.swift

@@ -79,7 +79,7 @@ class StickyNoteViewController : NSViewController, NSTextFieldDelegate {
                                         ["z":"zither"]])
 
         client = Client(address:address)
-        let call = client.makeCall(host: requestHost, method: requestMethod, timeout: 600)
+        let call = client.makeCall(host: requestHost, method: requestMethod)
         try call.performNonStreamingCall(message: requestMessage.data(),
                                          metadata: requestMetadata,
                                          completion:

+ 4 - 1
Packages/gRPC/Sources/Client.swift

@@ -44,6 +44,9 @@ public class Client {
   /// Completion queue for client call operations
   private var completionQueue: CompletionQueue
 
+  /// Timeout for client requests
+  public var timeout: TimeInterval = 600.0
+
   /// Initializes a gRPC client
   ///
   /// - Parameter address: the address of the server to be called
@@ -82,7 +85,7 @@ public class Client {
   /// - Parameter method: the gRPC method name for the call
   /// - Parameter timeout: a timeout value in seconds
   /// - Returns: a Call object that can be used to perform the request
-  public func makeCall(host:String, method:String, timeout:TimeInterval) -> Call {
+  public func makeCall(host:String, method:String) -> Call {
     let underlyingCall = cgrpc_client_create_call(underlyingClient, method, host, timeout)!
     return Call(underlyingCall:underlyingCall, owned:true, completionQueue:self.completionQueue)
   }