Procházet zdrojové kódy

Fix the tests and add the output binary of the Echo PackageManager example to .gitignore.

Daniel Alm před 8 roky
rodič
revize
46477bedc6

+ 1 - 1
.gitignore

@@ -8,6 +8,6 @@ Plugin/Sources/protoc-gen-swiftgrpc/templates.swift
 Plugin/protoc-*
 Plugin/swiftgrpc.log
 Plugin/echo.*.swift
-ExampleTests/Generated
+Examples/Echo/PackageManager/Echo
 SwiftGRPC.xcodeproj
 Package.resolved

+ 2 - 2
Examples/Echo/EchoProvider.swift

@@ -32,7 +32,7 @@ class EchoProvider: Echo_EchoProvider {
       var response = Echo_EchoResponse()
       response.text = "Swift echo expand (\(i)): \(part)"
       let sem = DispatchSemaphore(value: 0)
-      try session.send(response) { sem.signal() }
+      try session.send(response) { _ in sem.signal() }
       _ = sem.wait(timeout: DispatchTime.distantFuture)
       i += 1
       sleep(1)
@@ -67,7 +67,7 @@ class EchoProvider: Echo_EchoProvider {
         var response = Echo_EchoResponse()
         response.text = "Swift echo update (\(count)): \(request.text)"
         let sem = DispatchSemaphore(value: 0)
-        try session.send(response) { sem.signal() }
+        try session.send(response) { _ in sem.signal() }
         _ = sem.wait(timeout: DispatchTime.distantFuture)
       } catch Echo_EchoServerError.endOfStream {
         break

+ 4 - 4
Examples/Echo/Generated/echo.grpc.swift

@@ -215,7 +215,7 @@ fileprivate final class Echo_EchoCollectCallImpl: Echo_EchoCollectCall {
   }
 
   /// Call this to start a call. Nonblocking.
-  func start(metadata:Metadata, completion: (CallResult)->()?)
+  func start(metadata:Metadata, completion: ((CallResult)->())?)
     throws -> Echo_EchoCollectCall {
       try self.call.start(.clientStreaming, metadata:metadata, completion:completion)
       return self
@@ -366,19 +366,19 @@ internal protocol Echo_EchoService {
   /// Asynchronous. Server-streaming.
   /// Send the initial message.
   /// Use methods on the returned object to get streamed responses.
-  func expand(_ request: Echo_EchoRequest, completion: @escaping (CallResult)->())
+  func expand(_ request: Echo_EchoRequest, completion: ((CallResult)->())?)
     throws -> Echo_EchoExpandCall
 
   /// Asynchronous. Client-streaming.
   /// Use methods on the returned object to stream messages and
   /// to close the connection and wait for a final response.
-  func collect(completion: @escaping (CallResult)->())
+  func collect(completion: ((CallResult)->())?)
     throws -> Echo_EchoCollectCall
 
   /// Asynchronous. Bidirectional-streaming.
   /// Use methods on the returned object to stream messages,
   /// to wait for replies, and to close the connection.
-  func update(completion: @escaping (CallResult)->())
+  func update(completion: ((CallResult)->())?)
     throws -> Echo_EchoUpdateCall
 
 }

+ 1 - 1
Examples/Simple/PackageManager/main.swift

@@ -115,7 +115,7 @@ func server() throws {
     }
   }
 
-  server.onCompletion {
+  server.onCompletion = {
     print("Server Stopped")
   }
 

+ 1 - 1
Plugin/Templates/client-call-clientstreaming.swift

@@ -43,7 +43,7 @@ fileprivate final class {{ .|call:file,service,method }}Impl: {{ .|call:file,ser
   }
 
   /// Call this to start a call. Nonblocking.
-  func start(metadata:Metadata, completion: (CallResult)->()?)
+  func start(metadata:Metadata, completion: ((CallResult)->())?)
     throws -> {{ .|call:file,service,method }} {
       try self.call.start(.clientStreaming, metadata:metadata, completion:completion)
       return self

+ 6 - 6
Plugin/Templates/client.swift

@@ -49,21 +49,21 @@
   /// Asynchronous. Server-streaming.
   /// Send the initial message.
   /// Use methods on the returned object to get streamed responses.
-  func {{ method|methodDescriptorName|lowercase }}(_ request: {{ method|input }}, completion: @escaping (CallResult)->())
+  func {{ method|methodDescriptorName|lowercase }}(_ request: {{ method|input }}, completion: ((CallResult)->())?)
     throws -> {{ .|call:file,service,method }}
   //-{% endif %}
   //-{% if method|methodIsClientStreaming %}
   /// Asynchronous. Client-streaming.
   /// Use methods on the returned object to stream messages and
   /// to close the connection and wait for a final response.
-  func {{ method|methodDescriptorName|lowercase }}(completion: @escaping (CallResult)->())
+  func {{ method|methodDescriptorName|lowercase }}(completion: ((CallResult)->())?)
     throws -> {{ .|call:file,service,method }}
   //-{% endif %}
   //-{% if method|methodIsBidiStreaming %}
   /// Asynchronous. Bidirectional-streaming.
   /// Use methods on the returned object to stream messages,
   /// to wait for replies, and to close the connection.
-  func {{ method|methodDescriptorName|lowercase }}(completion: @escaping (CallResult)->())
+  func {{ method|methodDescriptorName|lowercase }}(completion: ((CallResult)->())?)
     throws -> {{ .|call:file,service,method }}
   //-{% endif %}
 
@@ -186,7 +186,7 @@ class {{ .|serviceclass:file,service }}TestStub: {{ .|serviceclass:file,service
   //-{% if method|methodIsServerStreaming %}
   var {{ method|methodDescriptorName|lowercase }}Requests: [{{ method|input }}] = []
   var {{ method|methodDescriptorName|lowercase }}Calls: [{{ .|call:file,service,method }}] = []
-  func {{ method|methodDescriptorName|lowercase }}(_ request: {{ method|input }}, completion: @escaping (CallResult)->())
+  func {{ method|methodDescriptorName|lowercase }}(_ request: {{ method|input }}, completion: ((CallResult)->())?)
     throws -> {{ .|call:file,service,method }} {
       {{ method|methodDescriptorName|lowercase }}Requests.append(request)
       defer { {{ method|methodDescriptorName|lowercase }}Calls.removeFirst() }
@@ -195,7 +195,7 @@ class {{ .|serviceclass:file,service }}TestStub: {{ .|serviceclass:file,service
   //-{% endif %}
   //-{% if method|methodIsClientStreaming %}
   var {{ method|methodDescriptorName|lowercase }}Calls: [{{ .|call:file,service,method }}] = []
-  func {{ method|methodDescriptorName|lowercase }}(completion: @escaping (CallResult)->())
+  func {{ method|methodDescriptorName|lowercase }}(completion: ((CallResult)->())?)
     throws -> {{ .|call:file,service,method }} {
       defer { {{ method|methodDescriptorName|lowercase }}Calls.removeFirst() }
       return {{ method|methodDescriptorName|lowercase }}Calls.first!
@@ -203,7 +203,7 @@ class {{ .|serviceclass:file,service }}TestStub: {{ .|serviceclass:file,service
   //-{% endif %}
   //-{% if method|methodIsBidiStreaming %}
   var {{ method|methodDescriptorName|lowercase }}Calls: [{{ .|call:file,service,method }}] = []
-  func {{ method|methodDescriptorName|lowercase }}(completion: @escaping (CallResult)->())
+  func {{ method|methodDescriptorName|lowercase }}(completion: ((CallResult)->())?)
     throws -> {{ .|call:file,service,method }} {
       defer { {{ method|methodDescriptorName|lowercase }}Calls.removeFirst() }
       return {{ method|methodDescriptorName|lowercase }}Calls.first!