Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline service name into the generated path #633

Merged
merged 1 commit into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Sources/Examples/Echo/Model/echo.grpc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ public protocol Echo_EchoService {
func update(callOptions: CallOptions?, handler: @escaping (Echo_EchoResponse) -> Void) -> BidirectionalStreamingCall<Echo_EchoRequest, Echo_EchoResponse>
}

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.
Expand All @@ -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<Echo_EchoRequest, Echo_EchoResponse> {
return self.makeUnaryCall(path: self.path(forMethod: "Get"),
return self.makeUnaryCall(path: "/echo.Echo/Get",
request: request,
callOptions: callOptions ?? self.defaultCallOptions)
}
Expand All @@ -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<Echo_EchoRequest, Echo_EchoResponse> {
return self.makeServerStreamingCall(path: self.path(forMethod: "Expand"),
return self.makeServerStreamingCall(path: "/echo.Echo/Expand",
request: request,
callOptions: callOptions ?? self.defaultCallOptions,
handler: handler)
Expand All @@ -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<Echo_EchoRequest, Echo_EchoResponse> {
return self.makeClientStreamingCall(path: self.path(forMethod: "Collect"),
return self.makeClientStreamingCall(path: "/echo.Echo/Collect",
callOptions: callOptions ?? self.defaultCallOptions)
}

Expand All @@ -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<Echo_EchoRequest, Echo_EchoResponse> {
return self.makeBidirectionalStreamingCall(path: self.path(forMethod: "Update"),
return self.makeBidirectionalStreamingCall(path: "/echo.Echo/Update",
callOptions: callOptions ?? self.defaultCallOptions,
handler: handler)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Examples/Echo/Model/echo.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions Sources/Examples/HelloWorld/Model/helloworld.grpc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ public protocol Helloworld_GreeterService {
func sayHello(_ request: Helloworld_HelloRequest, callOptions: CallOptions?) -> UnaryCall<Helloworld_HelloRequest, Helloworld_HelloReply>
}

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.
Expand All @@ -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<Helloworld_HelloRequest, Helloworld_HelloReply> {
return self.makeUnaryCall(path: self.path(forMethod: "SayHello"),
return self.makeUnaryCall(path: "/helloworld.Greeter/SayHello",
request: request,
callOptions: callOptions ?? self.defaultCallOptions)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Examples/HelloWorld/Model/helloworld.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 5 additions & 6 deletions Sources/Examples/RouteGuide/Model/route_guide.grpc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ public protocol Routeguide_RouteGuideService {
func routeChat(callOptions: CallOptions?, handler: @escaping (Routeguide_RouteNote) -> Void) -> BidirectionalStreamingCall<Routeguide_RouteNote, Routeguide_RouteNote>
}

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.
Expand All @@ -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<Routeguide_Point, Routeguide_Feature> {
return self.makeUnaryCall(path: self.path(forMethod: "GetFeature"),
return self.makeUnaryCall(path: "/routeguide.RouteGuide/GetFeature",
request: request,
callOptions: callOptions ?? self.defaultCallOptions)
}
Expand All @@ -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<Routeguide_Rectangle, Routeguide_Feature> {
return self.makeServerStreamingCall(path: self.path(forMethod: "ListFeatures"),
return self.makeServerStreamingCall(path: "/routeguide.RouteGuide/ListFeatures",
request: request,
callOptions: callOptions ?? self.defaultCallOptions,
handler: handler)
Expand All @@ -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<Routeguide_Point, Routeguide_RouteSummary> {
return self.makeClientStreamingCall(path: self.path(forMethod: "RecordRoute"),
return self.makeClientStreamingCall(path: "/routeguide.RouteGuide/RecordRoute",
callOptions: callOptions ?? self.defaultCallOptions)
}

Expand All @@ -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<Routeguide_RouteNote, Routeguide_RouteNote> {
return self.makeBidirectionalStreamingCall(path: self.path(forMethod: "RouteChat"),
return self.makeBidirectionalStreamingCall(path: "/routeguide.RouteGuide/RouteChat",
callOptions: callOptions ?? self.defaultCallOptions,
handler: handler)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Examples/RouteGuide/Model/route_guide.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 0 additions & 21 deletions Sources/GRPC/GRPCClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading