Browse Source

Two compilation/test fixes.

Daniel Alm 7 years ago
parent
commit
64e9d93de4
2 changed files with 19 additions and 13 deletions
  1. 10 7
      Examples/Echo/Generated/echo.grpc.swift
  2. 9 6
      Plugin/Templates/server.swift

+ 10 - 7
Examples/Echo/Generated/echo.grpc.swift

@@ -385,7 +385,7 @@ internal protocol Echo_EchoService {
 
 }
 
-internal final class Echo_EchoServiceImpl: Echo_EchoService {
+internal final class Echo_EchoServiceClient: Echo_EchoService {
   internal private(set) var channel: Channel
 
   internal var metadata : Metadata
@@ -749,13 +749,16 @@ internal final class Echo_EchoServer {
       fatalError() // the server requires a provider
     }
     server.run {(handler) in
-      print("Server received request to " + handler.host
-        + " calling " + handler.method
-        + " from " + handler.caller
-        + " with " + String(describing:handler.requestMetadata) )
+      let unwrappedHost = handler.host ?? "(nil)"
+      let unwrappedMethod = handler.method ?? "(nil)"
+      let unwrappedCaller = handler.caller ?? "(nil)"
+      print("Server received request to " + unwrappedHost
+        + " calling " + unwrappedMethod
+        + " from " + unwrappedCaller
+        + " with " + handler.requestMetadata.description)
 
       do {
-        switch handler.method {
+        switch unwrappedMethod {
         case "/echo.Echo/Get":
           try Echo_EchoGetSessionImpl(handler:handler, provider:provider).run(queue:queue)
         case "/echo.Echo/Expand":
@@ -768,7 +771,7 @@ internal final class Echo_EchoServer {
           // handle unknown requests
           try handler.receiveMessage(initialMetadata:Metadata()) {(requestData) in
             try handler.sendResponse(statusCode:.unimplemented,
-                                     statusMessage:"unknown method " + handler.method,
+                                     statusMessage:"unknown method " + unwrappedMethod,
                                      trailingMetadata:Metadata())
           }
         }

+ 9 - 6
Plugin/Templates/server.swift

@@ -111,13 +111,16 @@ class {{ .|service:file,service }}SessionTestStub: {{ .|service:file,service }}S
       fatalError() // the server requires a provider
     }
     server.run {(handler) in
-      print("Server received request to " + handler.host
-        + " calling " + handler.method
-        + " from " + handler.caller
-        + " with " + String(describing:handler.requestMetadata) )
+      let unwrappedHost = handler.host ?? "(nil)"
+      let unwrappedMethod = handler.method ?? "(nil)"
+      let unwrappedCaller = handler.caller ?? "(nil)"
+      print("Server received request to " + unwrappedHost
+        + " calling " + unwrappedMethod
+        + " from " + unwrappedCaller
+        + " with " + handler.requestMetadata.description)
 
       do {
-        switch handler.method {
+        switch unwrappedMethod {
         //-{% for method in service.methods %}
         case "{{ .|path:file,service,method }}":
           try {{ .|session:file,service,method }}Impl(handler:handler, provider:provider).run(queue:queue)
@@ -126,7 +129,7 @@ class {{ .|service:file,service }}SessionTestStub: {{ .|service:file,service }}S
           // handle unknown requests
           try handler.receiveMessage(initialMetadata:Metadata()) {(requestData) in
             try handler.sendResponse(statusCode:.unimplemented,
-                                     statusMessage:"unknown method " + handler.method,
+                                     statusMessage:"unknown method " + unwrappedMethod,
                                      trailingMetadata:Metadata())
           }
         }