Pārlūkot izejas kodu

minor streamlining, preparing to better track call status in clients

Tim Burks 9 gadi atpakaļ
vecāks
revīzija
2921c8fc38

+ 6 - 4
Examples/Echo/Swift/Generated/echo.client.pb.swift

@@ -99,8 +99,8 @@ public class Echo_EchoExpandCall {
   fileprivate func run(request: Echo_EchoRequest, metadata: Metadata) throws -> Echo_EchoExpandCall {
     let requestMessageData = try request.serializeProtobuf()
     try call.startServerStreaming(message: requestMessageData,
-                                  metadata: metadata,
-                                  completion:{(CallResult) in })
+                                  metadata: metadata)
+    {_ in}
     return self
   }
 
@@ -145,7 +145,8 @@ public class Echo_EchoCollectCall {
 
   // Call this to start a call.
   fileprivate func run(metadata:Metadata) throws -> Echo_EchoCollectCall {
-    try self.call.start(metadata: metadata, completion:{_ in})
+    try self.call.start(metadata: metadata)
+    {_ in}
     return self
   }
 
@@ -219,7 +220,8 @@ public class Echo_EchoUpdateCall {
   }
 
   fileprivate func run(metadata:Metadata) throws -> Echo_EchoUpdateCall {
-    try self.call.start(metadata: metadata, completion:{_ in})
+    try self.call.start(metadata: metadata)
+    {_ in}
     return self
   }
 

+ 2 - 1
Plugin/swiftgrpc.templates/client-call-bidistreaming.swift

@@ -8,7 +8,8 @@ public class {{ .|call:protoFile,service,method }} {
   }
 
   fileprivate func run(metadata:Metadata) throws -> {{ .|call:protoFile,service,method }} {
-    try self.call.start(metadata: metadata, completion:{_ in})
+    try self.call.start(metadata: metadata)
+    {_ in}
     return self
   }
 

+ 2 - 1
Plugin/swiftgrpc.templates/client-call-clientstreaming.swift

@@ -9,7 +9,8 @@ public class {{ .|call:protoFile,service,method }} {
 
   // Call this to start a call.
   fileprivate func run(metadata:Metadata) throws -> {{ .|call:protoFile,service,method }} {
-    try self.call.start(metadata: metadata, completion:{_ in})
+    try self.call.start(metadata: metadata)
+    {_ in}
     return self
   }
 

+ 2 - 2
Plugin/swiftgrpc.templates/client-call-serverstreaming.swift

@@ -11,8 +11,8 @@ public class {{ .|call:protoFile,service,method }} {
   fileprivate func run(request: {{ method|input }}, metadata: Metadata) throws -> {{ .|call:protoFile,service,method }} {
     let requestMessageData = try request.serializeProtobuf()
     try call.startServerStreaming(message: requestMessageData,
-                                  metadata: metadata,
-                                  completion:{(CallResult) in })
+                                  metadata: metadata)
+    {_ in}
     return self
   }
 

+ 2 - 2
Sources/gRPC/Call.swift

@@ -103,10 +103,10 @@ public struct CallResult {
 public class Call {
 
   /// Shared mutex for synchronizing calls to cgrpc_call_perform()
-  static let callMutex = Mutex()
+  private static let callMutex = Mutex()
 
   /// Maximum number of messages that can be queued
-  static var maximumQueuedMessages = 10
+  private static var maximumQueuedMessages = 10
 
   /// Pointer to underlying C representation
   private var underlyingCall : UnsafeMutableRawPointer