From fad56707c1e9251455ec9e6050050d1dc59b5ed8 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Wed, 13 Nov 2019 14:21:26 +0000 Subject: [PATCH] Inline service name into the generated path Motivation: We gave users the option to customise how the path for the RPC was formatted. The protocol allows this but discourages it. Modifications: - Inline the service name into the generated code - Remove GRPCServiceClient and just use GRPCClient - Update generated code Result: - Users are now discouraged in the strongest possible way to not use custom paths. - Generated code is simpler. --- Sources/Examples/Echo/Model/echo.grpc.swift | 11 +++---- Sources/Examples/Echo/Model/echo.pb.swift | 2 +- .../HelloWorld/Model/helloworld.grpc.swift | 5 ++- .../HelloWorld/Model/helloworld.pb.swift | 2 +- .../RouteGuide/Model/route_guide.grpc.swift | 11 +++---- .../RouteGuide/Model/route_guide.pb.swift | 2 +- Sources/GRPC/GRPCClient.swift | 21 ------------- .../Generated/empty.pb.swift | 2 +- .../Generated/messages.pb.swift | 2 +- .../Generated/test.grpc.swift | 31 +++++++++---------- .../Generated/test.pb.swift | 2 +- .../Generator-Client.swift | 11 +++---- 12 files changed, 37 insertions(+), 65 deletions(-) diff --git a/Sources/Examples/Echo/Model/echo.grpc.swift b/Sources/Examples/Echo/Model/echo.grpc.swift index 2d79a6998..1efc8e608 100644 --- a/Sources/Examples/Echo/Model/echo.grpc.swift +++ b/Sources/Examples/Echo/Model/echo.grpc.swift @@ -35,9 +35,8 @@ public protocol Echo_EchoService { func update(callOptions: CallOptions?, handler: @escaping (Echo_EchoResponse) -> Void) -> BidirectionalStreamingCall } -public final class Echo_EchoServiceClient: GRPCServiceClient, Echo_EchoService { +public final class Echo_EchoServiceClient: GRPCClient, Echo_EchoService { public let connection: ClientConnection - public var serviceName: String { return "echo.Echo" } public var defaultCallOptions: CallOptions /// Creates a client for the echo.Echo service. @@ -57,7 +56,7 @@ public final class Echo_EchoServiceClient: GRPCServiceClient, Echo_EchoService { /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func get(_ request: Echo_EchoRequest, callOptions: CallOptions? = nil) -> UnaryCall { - return self.makeUnaryCall(path: self.path(forMethod: "Get"), + return self.makeUnaryCall(path: "/echo.Echo/Get", request: request, callOptions: callOptions ?? self.defaultCallOptions) } @@ -70,7 +69,7 @@ public final class Echo_EchoServiceClient: GRPCServiceClient, Echo_EchoService { /// - handler: A closure called when each response is received from the server. /// - Returns: A `ServerStreamingCall` with futures for the metadata and status. public func expand(_ request: Echo_EchoRequest, callOptions: CallOptions? = nil, handler: @escaping (Echo_EchoResponse) -> Void) -> ServerStreamingCall { - return self.makeServerStreamingCall(path: self.path(forMethod: "Expand"), + return self.makeServerStreamingCall(path: "/echo.Echo/Expand", request: request, callOptions: callOptions ?? self.defaultCallOptions, handler: handler) @@ -85,7 +84,7 @@ public final class Echo_EchoServiceClient: GRPCServiceClient, Echo_EchoService { /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response. public func collect(callOptions: CallOptions? = nil) -> ClientStreamingCall { - return self.makeClientStreamingCall(path: self.path(forMethod: "Collect"), + return self.makeClientStreamingCall(path: "/echo.Echo/Collect", callOptions: callOptions ?? self.defaultCallOptions) } @@ -99,7 +98,7 @@ public final class Echo_EchoServiceClient: GRPCServiceClient, Echo_EchoService { /// - handler: A closure called when each response is received from the server. /// - Returns: A `ClientStreamingCall` with futures for the metadata and status. public func update(callOptions: CallOptions? = nil, handler: @escaping (Echo_EchoResponse) -> Void) -> BidirectionalStreamingCall { - return self.makeBidirectionalStreamingCall(path: self.path(forMethod: "Update"), + return self.makeBidirectionalStreamingCall(path: "/echo.Echo/Update", callOptions: callOptions ?? self.defaultCallOptions, handler: handler) } diff --git a/Sources/Examples/Echo/Model/echo.pb.swift b/Sources/Examples/Echo/Model/echo.pb.swift index 733d45b23..38bedff04 100644 --- a/Sources/Examples/Echo/Model/echo.pb.swift +++ b/Sources/Examples/Echo/Model/echo.pb.swift @@ -3,7 +3,7 @@ // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: echo.proto // -// For information on using the generated types, please see the documenation: +// For information on using the generated types, please see the documentation: // https://github.com/apple/swift-protobuf/ // Copyright (c) 2015, Google Inc. diff --git a/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift b/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift index e91cb7fab..fee249b01 100644 --- a/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift +++ b/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift @@ -32,9 +32,8 @@ public protocol Helloworld_GreeterService { func sayHello(_ request: Helloworld_HelloRequest, callOptions: CallOptions?) -> UnaryCall } -public final class Helloworld_GreeterServiceClient: GRPCServiceClient, Helloworld_GreeterService { +public final class Helloworld_GreeterServiceClient: GRPCClient, Helloworld_GreeterService { public let connection: ClientConnection - public var serviceName: String { return "helloworld.Greeter" } public var defaultCallOptions: CallOptions /// Creates a client for the helloworld.Greeter service. @@ -54,7 +53,7 @@ public final class Helloworld_GreeterServiceClient: GRPCServiceClient, Helloworl /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func sayHello(_ request: Helloworld_HelloRequest, callOptions: CallOptions? = nil) -> UnaryCall { - return self.makeUnaryCall(path: self.path(forMethod: "SayHello"), + return self.makeUnaryCall(path: "/helloworld.Greeter/SayHello", request: request, callOptions: callOptions ?? self.defaultCallOptions) } diff --git a/Sources/Examples/HelloWorld/Model/helloworld.pb.swift b/Sources/Examples/HelloWorld/Model/helloworld.pb.swift index 7f9f10ef4..aca815d51 100644 --- a/Sources/Examples/HelloWorld/Model/helloworld.pb.swift +++ b/Sources/Examples/HelloWorld/Model/helloworld.pb.swift @@ -3,7 +3,7 @@ // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: helloworld.proto // -// For information on using the generated types, please see the documenation: +// For information on using the generated types, please see the documentation: // https://github.com/apple/swift-protobuf/ // Copyright 2015 gRPC authors. diff --git a/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift b/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift index 4e6633b0f..32319c599 100644 --- a/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift +++ b/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift @@ -35,9 +35,8 @@ public protocol Routeguide_RouteGuideService { func routeChat(callOptions: CallOptions?, handler: @escaping (Routeguide_RouteNote) -> Void) -> BidirectionalStreamingCall } -public final class Routeguide_RouteGuideServiceClient: GRPCServiceClient, Routeguide_RouteGuideService { +public final class Routeguide_RouteGuideServiceClient: GRPCClient, Routeguide_RouteGuideService { public let connection: ClientConnection - public var serviceName: String { return "routeguide.RouteGuide" } public var defaultCallOptions: CallOptions /// Creates a client for the routeguide.RouteGuide service. @@ -57,7 +56,7 @@ public final class Routeguide_RouteGuideServiceClient: GRPCServiceClient, Routeg /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func getFeature(_ request: Routeguide_Point, callOptions: CallOptions? = nil) -> UnaryCall { - return self.makeUnaryCall(path: self.path(forMethod: "GetFeature"), + return self.makeUnaryCall(path: "/routeguide.RouteGuide/GetFeature", request: request, callOptions: callOptions ?? self.defaultCallOptions) } @@ -70,7 +69,7 @@ public final class Routeguide_RouteGuideServiceClient: GRPCServiceClient, Routeg /// - handler: A closure called when each response is received from the server. /// - Returns: A `ServerStreamingCall` with futures for the metadata and status. public func listFeatures(_ request: Routeguide_Rectangle, callOptions: CallOptions? = nil, handler: @escaping (Routeguide_Feature) -> Void) -> ServerStreamingCall { - return self.makeServerStreamingCall(path: self.path(forMethod: "ListFeatures"), + return self.makeServerStreamingCall(path: "/routeguide.RouteGuide/ListFeatures", request: request, callOptions: callOptions ?? self.defaultCallOptions, handler: handler) @@ -85,7 +84,7 @@ public final class Routeguide_RouteGuideServiceClient: GRPCServiceClient, Routeg /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response. public func recordRoute(callOptions: CallOptions? = nil) -> ClientStreamingCall { - return self.makeClientStreamingCall(path: self.path(forMethod: "RecordRoute"), + return self.makeClientStreamingCall(path: "/routeguide.RouteGuide/RecordRoute", callOptions: callOptions ?? self.defaultCallOptions) } @@ -99,7 +98,7 @@ public final class Routeguide_RouteGuideServiceClient: GRPCServiceClient, Routeg /// - handler: A closure called when each response is received from the server. /// - Returns: A `ClientStreamingCall` with futures for the metadata and status. public func routeChat(callOptions: CallOptions? = nil, handler: @escaping (Routeguide_RouteNote) -> Void) -> BidirectionalStreamingCall { - return self.makeBidirectionalStreamingCall(path: self.path(forMethod: "RouteChat"), + return self.makeBidirectionalStreamingCall(path: "/routeguide.RouteGuide/RouteChat", callOptions: callOptions ?? self.defaultCallOptions, handler: handler) } diff --git a/Sources/Examples/RouteGuide/Model/route_guide.pb.swift b/Sources/Examples/RouteGuide/Model/route_guide.pb.swift index 76bc7e771..fe8cf5024 100644 --- a/Sources/Examples/RouteGuide/Model/route_guide.pb.swift +++ b/Sources/Examples/RouteGuide/Model/route_guide.pb.swift @@ -3,7 +3,7 @@ // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: route_guide.proto // -// For information on using the generated types, please see the documenation: +// For information on using the generated types, please see the documentation: // https://github.com/apple/swift-protobuf/ // Copyright 2015 gRPC authors. diff --git a/Sources/GRPC/GRPCClient.swift b/Sources/GRPC/GRPCClient.swift index 5fe8e5113..35f897481 100644 --- a/Sources/GRPC/GRPCClient.swift +++ b/Sources/GRPC/GRPCClient.swift @@ -85,27 +85,6 @@ extension GRPCClient { } } -/// A GRPC client for a named service. -public protocol GRPCServiceClient: GRPCClient { - /// Name of the service this client is for (e.g. "echo.Echo"). - var serviceName: String { get } - - /// Creates a path for a given method on this service. - /// - /// This defaults to "/Service-Name/Method-Name" but may be overriden if consumers - /// require a different path format. - /// - /// - Parameter method: name of method to return a path for. - /// - Returns: path for the given method used in gRPC request headers. - func path(forMethod method: String) -> String -} - -extension GRPCServiceClient { - public func path(forMethod method: String) -> String { - return "/\(self.serviceName)/\(method)" - } -} - /// A client which has no generated stubs and may be used to create gRPC calls manually. /// See `GRPCClient` for details. public final class AnyServiceClient: GRPCClient { diff --git a/Sources/GRPCInteroperabilityTestModels/Generated/empty.pb.swift b/Sources/GRPCInteroperabilityTestModels/Generated/empty.pb.swift index b1ebd940d..857a5aa0e 100644 --- a/Sources/GRPCInteroperabilityTestModels/Generated/empty.pb.swift +++ b/Sources/GRPCInteroperabilityTestModels/Generated/empty.pb.swift @@ -3,7 +3,7 @@ // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: src/proto/grpc/testing/empty.proto // -// For information on using the generated types, please see the documenation: +// For information on using the generated types, please see the documentation: // https://github.com/apple/swift-protobuf/ // Copyright 2015 gRPC authors. diff --git a/Sources/GRPCInteroperabilityTestModels/Generated/messages.pb.swift b/Sources/GRPCInteroperabilityTestModels/Generated/messages.pb.swift index dfdf950d4..fa8a60dc0 100644 --- a/Sources/GRPCInteroperabilityTestModels/Generated/messages.pb.swift +++ b/Sources/GRPCInteroperabilityTestModels/Generated/messages.pb.swift @@ -3,7 +3,7 @@ // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: src/proto/grpc/testing/messages.proto // -// For information on using the generated types, please see the documenation: +// For information on using the generated types, please see the documentation: // https://github.com/apple/swift-protobuf/ // Copyright 2015-2016 gRPC authors. diff --git a/Sources/GRPCInteroperabilityTestModels/Generated/test.grpc.swift b/Sources/GRPCInteroperabilityTestModels/Generated/test.grpc.swift index 486554cb3..3d9b1b889 100644 --- a/Sources/GRPCInteroperabilityTestModels/Generated/test.grpc.swift +++ b/Sources/GRPCInteroperabilityTestModels/Generated/test.grpc.swift @@ -39,9 +39,8 @@ public protocol Grpc_Testing_TestServiceService { func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions?) -> UnaryCall } -public final class Grpc_Testing_TestServiceServiceClient: GRPCServiceClient, Grpc_Testing_TestServiceService { +public final class Grpc_Testing_TestServiceServiceClient: GRPCClient, Grpc_Testing_TestServiceService { public let connection: ClientConnection - public var serviceName: String { return "grpc.testing.TestService" } public var defaultCallOptions: CallOptions /// Creates a client for the grpc.testing.TestService service. @@ -61,7 +60,7 @@ public final class Grpc_Testing_TestServiceServiceClient: GRPCServiceClient, Grp /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func emptyCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall { - return self.makeUnaryCall(path: self.path(forMethod: "EmptyCall"), + return self.makeUnaryCall(path: "/grpc.testing.TestService/EmptyCall", request: request, callOptions: callOptions ?? self.defaultCallOptions) } @@ -73,7 +72,7 @@ public final class Grpc_Testing_TestServiceServiceClient: GRPCServiceClient, Grp /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func unaryCall(_ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions? = nil) -> UnaryCall { - return self.makeUnaryCall(path: self.path(forMethod: "UnaryCall"), + return self.makeUnaryCall(path: "/grpc.testing.TestService/UnaryCall", request: request, callOptions: callOptions ?? self.defaultCallOptions) } @@ -85,7 +84,7 @@ public final class Grpc_Testing_TestServiceServiceClient: GRPCServiceClient, Grp /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func cacheableUnaryCall(_ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions? = nil) -> UnaryCall { - return self.makeUnaryCall(path: self.path(forMethod: "CacheableUnaryCall"), + return self.makeUnaryCall(path: "/grpc.testing.TestService/CacheableUnaryCall", request: request, callOptions: callOptions ?? self.defaultCallOptions) } @@ -98,7 +97,7 @@ public final class Grpc_Testing_TestServiceServiceClient: GRPCServiceClient, Grp /// - handler: A closure called when each response is received from the server. /// - Returns: A `ServerStreamingCall` with futures for the metadata and status. public func streamingOutputCall(_ request: Grpc_Testing_StreamingOutputCallRequest, callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> ServerStreamingCall { - return self.makeServerStreamingCall(path: self.path(forMethod: "StreamingOutputCall"), + return self.makeServerStreamingCall(path: "/grpc.testing.TestService/StreamingOutputCall", request: request, callOptions: callOptions ?? self.defaultCallOptions, handler: handler) @@ -113,7 +112,7 @@ public final class Grpc_Testing_TestServiceServiceClient: GRPCServiceClient, Grp /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response. public func streamingInputCall(callOptions: CallOptions? = nil) -> ClientStreamingCall { - return self.makeClientStreamingCall(path: self.path(forMethod: "StreamingInputCall"), + return self.makeClientStreamingCall(path: "/grpc.testing.TestService/StreamingInputCall", callOptions: callOptions ?? self.defaultCallOptions) } @@ -127,7 +126,7 @@ public final class Grpc_Testing_TestServiceServiceClient: GRPCServiceClient, Grp /// - handler: A closure called when each response is received from the server. /// - Returns: A `ClientStreamingCall` with futures for the metadata and status. public func fullDuplexCall(callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> BidirectionalStreamingCall { - return self.makeBidirectionalStreamingCall(path: self.path(forMethod: "FullDuplexCall"), + return self.makeBidirectionalStreamingCall(path: "/grpc.testing.TestService/FullDuplexCall", callOptions: callOptions ?? self.defaultCallOptions, handler: handler) } @@ -142,7 +141,7 @@ public final class Grpc_Testing_TestServiceServiceClient: GRPCServiceClient, Grp /// - handler: A closure called when each response is received from the server. /// - Returns: A `ClientStreamingCall` with futures for the metadata and status. public func halfDuplexCall(callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> BidirectionalStreamingCall { - return self.makeBidirectionalStreamingCall(path: self.path(forMethod: "HalfDuplexCall"), + return self.makeBidirectionalStreamingCall(path: "/grpc.testing.TestService/HalfDuplexCall", callOptions: callOptions ?? self.defaultCallOptions, handler: handler) } @@ -154,7 +153,7 @@ public final class Grpc_Testing_TestServiceServiceClient: GRPCServiceClient, Grp /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall { - return self.makeUnaryCall(path: self.path(forMethod: "UnimplementedCall"), + return self.makeUnaryCall(path: "/grpc.testing.TestService/UnimplementedCall", request: request, callOptions: callOptions ?? self.defaultCallOptions) } @@ -166,9 +165,8 @@ public protocol Grpc_Testing_UnimplementedServiceService { func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions?) -> UnaryCall } -public final class Grpc_Testing_UnimplementedServiceServiceClient: GRPCServiceClient, Grpc_Testing_UnimplementedServiceService { +public final class Grpc_Testing_UnimplementedServiceServiceClient: GRPCClient, Grpc_Testing_UnimplementedServiceService { public let connection: ClientConnection - public var serviceName: String { return "grpc.testing.UnimplementedService" } public var defaultCallOptions: CallOptions /// Creates a client for the grpc.testing.UnimplementedService service. @@ -188,7 +186,7 @@ public final class Grpc_Testing_UnimplementedServiceServiceClient: GRPCServiceCl /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall { - return self.makeUnaryCall(path: self.path(forMethod: "UnimplementedCall"), + return self.makeUnaryCall(path: "/grpc.testing.UnimplementedService/UnimplementedCall", request: request, callOptions: callOptions ?? self.defaultCallOptions) } @@ -201,9 +199,8 @@ public protocol Grpc_Testing_ReconnectServiceService { func stop(_ request: Grpc_Testing_Empty, callOptions: CallOptions?) -> UnaryCall } -public final class Grpc_Testing_ReconnectServiceServiceClient: GRPCServiceClient, Grpc_Testing_ReconnectServiceService { +public final class Grpc_Testing_ReconnectServiceServiceClient: GRPCClient, Grpc_Testing_ReconnectServiceService { public let connection: ClientConnection - public var serviceName: String { return "grpc.testing.ReconnectService" } public var defaultCallOptions: CallOptions /// Creates a client for the grpc.testing.ReconnectService service. @@ -223,7 +220,7 @@ public final class Grpc_Testing_ReconnectServiceServiceClient: GRPCServiceClient /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func start(_ request: Grpc_Testing_ReconnectParams, callOptions: CallOptions? = nil) -> UnaryCall { - return self.makeUnaryCall(path: self.path(forMethod: "Start"), + return self.makeUnaryCall(path: "/grpc.testing.ReconnectService/Start", request: request, callOptions: callOptions ?? self.defaultCallOptions) } @@ -235,7 +232,7 @@ public final class Grpc_Testing_ReconnectServiceServiceClient: GRPCServiceClient /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func stop(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall { - return self.makeUnaryCall(path: self.path(forMethod: "Stop"), + return self.makeUnaryCall(path: "/grpc.testing.ReconnectService/Stop", request: request, callOptions: callOptions ?? self.defaultCallOptions) } diff --git a/Sources/GRPCInteroperabilityTestModels/Generated/test.pb.swift b/Sources/GRPCInteroperabilityTestModels/Generated/test.pb.swift index 4a60ff7b6..9ad671416 100644 --- a/Sources/GRPCInteroperabilityTestModels/Generated/test.pb.swift +++ b/Sources/GRPCInteroperabilityTestModels/Generated/test.pb.swift @@ -3,7 +3,7 @@ // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: src/proto/grpc/testing/test.proto // -// For information on using the generated types, please see the documenation: +// For information on using the generated types, please see the documentation: // https://github.com/apple/swift-protobuf/ // Copyright 2015-2016 gRPC authors. diff --git a/Sources/protoc-gen-grpc-swift/Generator-Client.swift b/Sources/protoc-gen-grpc-swift/Generator-Client.swift index db7ca8b9a..e86a3c1d0 100644 --- a/Sources/protoc-gen-grpc-swift/Generator-Client.swift +++ b/Sources/protoc-gen-grpc-swift/Generator-Client.swift @@ -50,10 +50,9 @@ extension Generator { } private func printServiceClientImplementation() { - println("\(access) final class \(serviceClassName)Client: GRPCServiceClient, \(serviceClassName) {") + println("\(access) final class \(serviceClassName)Client: GRPCClient, \(serviceClassName) {") indent() println("\(access) let connection: ClientConnection") - println("\(access) var serviceName: String { return \"\(servicePath)\" }") println("\(access) var defaultCallOptions: CallOptions") println() println("/// Creates a client for the \(servicePath) service.") @@ -81,7 +80,7 @@ extension Generator { println("/// - Returns: A `UnaryCall` with futures for the metadata, status and response.") println("\(access) func \(methodFunctionName)(_ request: \(methodInputName), callOptions: CallOptions? = nil) -> UnaryCall<\(methodInputName), \(methodOutputName)> {") indent() - println("return self.makeUnaryCall(path: self.path(forMethod: \"\(method.name)\"),") + println("return self.makeUnaryCall(path: \"/\(servicePath)/\(method.name)\",") println(" request: request,") println(" callOptions: callOptions ?? self.defaultCallOptions)") outdent() @@ -97,7 +96,7 @@ extension Generator { println("/// - Returns: A `ServerStreamingCall` with futures for the metadata and status.") println("\(access) func \(methodFunctionName)(_ request: \(methodInputName), callOptions: CallOptions? = nil, handler: @escaping (\(methodOutputName)) -> Void) -> ServerStreamingCall<\(methodInputName), \(methodOutputName)> {") indent() - println("return self.makeServerStreamingCall(path: self.path(forMethod: \"\(method.name)\"),") + println("return self.makeServerStreamingCall(path: \"/\(servicePath)/\(method.name)\",") println(" request: request,") println(" callOptions: callOptions ?? self.defaultCallOptions,") println(" handler: handler)") @@ -114,7 +113,7 @@ extension Generator { println("/// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response.") println("\(access) func \(methodFunctionName)(callOptions: CallOptions? = nil) -> ClientStreamingCall<\(methodInputName), \(methodOutputName)> {") indent() - println("return self.makeClientStreamingCall(path: self.path(forMethod: \"\(method.name)\"),") + println("return self.makeClientStreamingCall(path: \"/\(servicePath)/\(method.name)\",") println(" callOptions: callOptions ?? self.defaultCallOptions)") outdent() println("}") @@ -130,7 +129,7 @@ extension Generator { println("/// - Returns: A `ClientStreamingCall` with futures for the metadata and status.") println("\(access) func \(methodFunctionName)(callOptions: CallOptions? = nil, handler: @escaping (\(methodOutputName)) -> Void) -> BidirectionalStreamingCall<\(methodInputName), \(methodOutputName)> {") indent() - println("return self.makeBidirectionalStreamingCall(path: self.path(forMethod: \"\(method.name)\"),") + println("return self.makeBidirectionalStreamingCall(path: \"/\(servicePath)/\(method.name)\",") println(" callOptions: callOptions ?? self.defaultCallOptions,") println(" handler: handler)") outdent()