Browse Source

Merge pull request #115 from takasek/channel_timeout

Let services to manipulate timeout without knowing its channel
Tim Burks 7 years ago
parent
commit
6cf7ca5679

+ 11 - 1
Examples/Echo/Generated/echo.grpc.swift

@@ -303,7 +303,7 @@ internal final class Echo_EchoUpdateCall {
 
 /// Call methods of this class to make API calls.
 internal final class Echo_EchoService {
-  public var channel: Channel
+  public private(set) var channel: Channel
 
   /// This metadata will be sent with all requests.
   internal var metadata : Metadata
@@ -320,6 +320,16 @@ internal final class Echo_EchoService {
     }
   }
 
+  /// This property allows the service timeout to be overridden.
+  internal var timeout : TimeInterval {
+    get {
+      return self.channel.timeout
+    }
+    set {
+      self.channel.timeout = newValue
+    }
+  }
+
   /// Create a client.
   internal init(address: String, secure: Bool = true) {
     gRPC.initialize()

File diff suppressed because it is too large
+ 0 - 0
Plugin/Sources/protoc-gen-swiftgrpc/templates.swift


+ 11 - 1
Plugin/Templates/client.swift

@@ -23,7 +23,7 @@
 //-{% endfor %}
 /// Call methods of this class to make API calls.
 {{ access }} final class {{ .|serviceclass:file,service }} {
-  public var channel: Channel
+  public private(set) var channel: Channel
 
   /// This metadata will be sent with all requests.
   {{ access }} var metadata : Metadata
@@ -40,6 +40,16 @@
     }
   }
 
+  /// This property allows the service timeout to be overridden.
+  {{ access }} var timeout : TimeInterval {
+    get {
+      return self.channel.timeout
+    }
+    set {
+      self.channel.timeout = newValue
+    }
+  }
+
   /// Create a client.
   {{ access }} init(address: String, secure: Bool = true) {
     gRPC.initialize()

Some files were not shown because too many files changed in this diff