Browse Source

Remove several now-unused DispatchQueue arguments.

Daniel Alm 7 years ago
parent
commit
9375cad761

+ 5 - 5
Sources/Examples/Echo/Generated/echo.grpc.swift

@@ -319,32 +319,32 @@ internal final class Echo_EchoServer: ServiceServer {
   }
 
   /// Start the server.
-  internal override func handleMethod(_ method: String, handler: Handler, queue: DispatchQueue) throws -> Bool {
+  internal override func handleMethod(_ method: String, handler: Handler) throws -> Bool {
     let provider = self.provider
     switch method {
     case "/echo.Echo/Get":
       try Echo_EchoGetSessionBase(
         handler: handler,
         providerBlock: { try provider.get(request: $0, session: $1 as! Echo_EchoGetSessionBase) })
-          .run(queue: queue)
+          .run()
       return true
     case "/echo.Echo/Expand":
       try Echo_EchoExpandSessionBase(
         handler: handler,
         providerBlock: { try provider.expand(request: $0, session: $1 as! Echo_EchoExpandSessionBase) })
-          .run(queue: queue)
+          .run()
       return true
     case "/echo.Echo/Collect":
       try Echo_EchoCollectSessionBase(
         handler: handler,
         providerBlock: { try provider.collect(session: $0 as! Echo_EchoCollectSessionBase) })
-          .run(queue: queue)
+          .run()
       return true
     case "/echo.Echo/Update":
       try Echo_EchoUpdateSessionBase(
         handler: handler,
         providerBlock: { try provider.update(session: $0 as! Echo_EchoUpdateSessionBase) })
-          .run(queue: queue)
+          .run()
       return true
     default:
       return false

+ 1 - 2
Sources/SwiftGRPC/Core/Server.swift

@@ -62,8 +62,7 @@ public class Server {
   }
 
   /// Run the server
-  public func run(dispatchQueue: DispatchQueue = DispatchQueue.global(),
-                  handlerFunction: @escaping (Handler) -> Void) {
+  public func run(handlerFunction: @escaping (Handler) -> Void) {
     cgrpc_server_start(underlyingServer)
     // run the server on a new background thread
     let spinloopThreadQueue = DispatchQueue(label: "SwiftGRPC.CompletionQueue.runToCompletion.spinloopThread")

+ 1 - 1
Sources/SwiftGRPC/Runtime/ServerSessionBidirectionalStreaming.swift

@@ -34,7 +34,7 @@ open class ServerSessionBidirectionalStreamingBase<InputType: Message, OutputTyp
     super.init(handler: handler)
   }
   
-  public func run(queue: DispatchQueue) throws {
+  public func run() throws {
     try handler.sendMetadata(initialMetadata: initialMetadata) { success in
       let handlerThreadQueue = DispatchQueue(label: "SwiftGRPC.ServerSessionBidirectionalStreamingBase.run.handlerThread")
       handlerThreadQueue.async {

+ 1 - 1
Sources/SwiftGRPC/Runtime/ServerSessionClientStreaming.swift

@@ -40,7 +40,7 @@ open class ServerSessionClientStreamingBase<InputType: Message, OutputType: Mess
     try handler.sendStatus(status, completion: completion)
   }
   
-  public func run(queue: DispatchQueue) throws {
+  public func run() throws {
     try handler.sendMetadata(initialMetadata: initialMetadata) { success in
       let handlerThreadQueue = DispatchQueue(label: "SwiftGRPC.ServerSessionClientStreamingBase.run.handlerThread")
       handlerThreadQueue.async {

+ 1 - 1
Sources/SwiftGRPC/Runtime/ServerSessionServerStreaming.swift

@@ -33,7 +33,7 @@ open class ServerSessionServerStreamingBase<InputType: Message, OutputType: Mess
     super.init(handler: handler)
   }
   
-  public func run(queue: DispatchQueue) throws {
+  public func run() throws {
     try handler.receiveMessage(initialMetadata: initialMetadata) { requestData in
       let handlerThreadQueue = DispatchQueue(label: "SwiftGRPC.ServerSessionServerStreamingBase.run.handlerThread")
       handlerThreadQueue.async {

+ 1 - 1
Sources/SwiftGRPC/Runtime/ServerSessionUnary.swift

@@ -31,7 +31,7 @@ open class ServerSessionUnaryBase<InputType: Message, OutputType: Message>: Serv
     super.init(handler: handler)
   }
   
-  public func run(queue: DispatchQueue) throws {
+  public func run() throws {
     try handler.receiveMessage(initialMetadata: initialMetadata) { requestData in
       let handlerThreadQueue = DispatchQueue(label: "SwiftGRPC.ServerSessionUnaryBase.run.handlerThread")
       handlerThreadQueue.async {

+ 3 - 3
Sources/SwiftGRPC/Runtime/ServiceServer.swift

@@ -50,10 +50,10 @@ open class ServiceServer {
 
   /// Handle the given method. Needs to be overridden by actual implementations.
   /// Returns whether the method was actually handled.
-  open func handleMethod(_ method: String, handler: Handler, queue: DispatchQueue) throws -> Bool { fatalError("needs to be overridden") }
+  open func handleMethod(_ method: String, handler: Handler) throws -> Bool { fatalError("needs to be overridden") }
 
   /// Start the server.
-  public func start(queue: DispatchQueue = DispatchQueue.global()) {
+  public func start() {
     server.run { [weak self] handler in
       guard let strongSelf = self else {
         print("ERROR: ServiceServer has been asked to handle a request even though it has already been deallocated")
@@ -71,7 +71,7 @@ open class ServiceServer {
       }
       
       do {
-        if !(try strongSelf.handleMethod(unwrappedMethod, handler: handler, queue: queue)) {
+        if !(try strongSelf.handleMethod(unwrappedMethod, handler: handler)) {
           do {
             try handler.call.perform(OperationGroup(
               call: handler.call,

+ 3 - 3
Sources/protoc-gen-swiftgrpc/Generator-Server.swift

@@ -89,7 +89,7 @@ extension Generator {
     println("}")
     println()
     println("/// Start the server.")
-    println("\(access) override func handleMethod(_ method: String, handler: Handler, queue: DispatchQueue) throws -> Bool {")
+    println("\(access) override func handleMethod(_ method: String, handler: Handler) throws -> Bool {")
     indent()
     println("let provider = self.provider")
     println("switch method {")
@@ -104,7 +104,7 @@ extension Generator {
         println("handler: handler,")
         println("providerBlock: { try provider.\(methodFunctionName)(request: $0, session: $1 as! \(methodSessionName)Base) })")
         indent()
-        println(".run(queue: queue)")
+        println(".run()")
         outdent()
         outdent()
       default:
@@ -113,7 +113,7 @@ extension Generator {
         println("handler: handler,")
         println("providerBlock: { try provider.\(methodFunctionName)(session: $0 as! \(methodSessionName)Base) })")
         indent()
-        println(".run(queue: queue)")
+        println(".run()")
         outdent()
         outdent()
       }

+ 2 - 2
Tests/SwiftGRPCTests/BasicEchoTestCase.swift

@@ -52,12 +52,12 @@ class BasicEchoTestCase: XCTestCase {
                                certificateString: certificateString,
                                keyString: String(data: keyForTests, encoding: .utf8)!,
                                provider: provider)
-      server.start(queue: DispatchQueue.global())
+      server.start()
       client = Echo_EchoServiceClient(address: address, certificates: certificateString, arguments: [.sslTargetNameOverride("example.com")])
       client.host = "example.com"
     } else {
       server = Echo_EchoServer(address: address, provider: provider)
-      server.start(queue: DispatchQueue.global())
+      server.start()
       client = Echo_EchoServiceClient(address: address, secure: false)
     }