route_guide.grpc.swift 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. //
  2. // DO NOT EDIT.
  3. //
  4. // Generated by the protocol buffer compiler.
  5. // Source: route_guide.proto
  6. //
  7. //
  8. // Copyright 2018, gRPC Authors All rights reserved.
  9. //
  10. // Licensed under the Apache License, Version 2.0 (the "License");
  11. // you may not use this file except in compliance with the License.
  12. // You may obtain a copy of the License at
  13. //
  14. // http://www.apache.org/licenses/LICENSE-2.0
  15. //
  16. // Unless required by applicable law or agreed to in writing, software
  17. // distributed under the License is distributed on an "AS IS" BASIS,
  18. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. // See the License for the specific language governing permissions and
  20. // limitations under the License.
  21. //
  22. import GRPC
  23. import NIO
  24. import NIOConcurrencyHelpers
  25. import SwiftProtobuf
  26. /// Interface exported by the server.
  27. ///
  28. /// Usage: instantiate `Routeguide_RouteGuideClient`, then call methods of this protocol to make API calls.
  29. public protocol Routeguide_RouteGuideClientProtocol: GRPCClient {
  30. var serviceName: String { get }
  31. var interceptors: Routeguide_RouteGuideClientInterceptorFactoryProtocol? { get }
  32. func getFeature(
  33. _ request: Routeguide_Point,
  34. callOptions: CallOptions?
  35. ) -> UnaryCall<Routeguide_Point, Routeguide_Feature>
  36. func listFeatures(
  37. _ request: Routeguide_Rectangle,
  38. callOptions: CallOptions?,
  39. handler: @escaping (Routeguide_Feature) -> Void
  40. ) -> ServerStreamingCall<Routeguide_Rectangle, Routeguide_Feature>
  41. func recordRoute(
  42. callOptions: CallOptions?
  43. ) -> ClientStreamingCall<Routeguide_Point, Routeguide_RouteSummary>
  44. func routeChat(
  45. callOptions: CallOptions?,
  46. handler: @escaping (Routeguide_RouteNote) -> Void
  47. ) -> BidirectionalStreamingCall<Routeguide_RouteNote, Routeguide_RouteNote>
  48. }
  49. extension Routeguide_RouteGuideClientProtocol {
  50. public var serviceName: String {
  51. return "routeguide.RouteGuide"
  52. }
  53. /// A simple RPC.
  54. ///
  55. /// Obtains the feature at a given position.
  56. ///
  57. /// A feature with an empty name is returned if there's no feature at the given
  58. /// position.
  59. ///
  60. /// - Parameters:
  61. /// - request: Request to send to GetFeature.
  62. /// - callOptions: Call options.
  63. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  64. public func getFeature(
  65. _ request: Routeguide_Point,
  66. callOptions: CallOptions? = nil
  67. ) -> UnaryCall<Routeguide_Point, Routeguide_Feature> {
  68. return self.makeUnaryCall(
  69. path: Routeguide_RouteGuideClientMetadata.Methods.getFeature.path,
  70. request: request,
  71. callOptions: callOptions ?? self.defaultCallOptions,
  72. interceptors: self.interceptors?.makeGetFeatureInterceptors() ?? []
  73. )
  74. }
  75. /// A server-to-client streaming RPC.
  76. ///
  77. /// Obtains the Features available within the given Rectangle. Results are
  78. /// streamed rather than returned at once (e.g. in a response message with a
  79. /// repeated field), as the rectangle may cover a large area and contain a
  80. /// huge number of features.
  81. ///
  82. /// - Parameters:
  83. /// - request: Request to send to ListFeatures.
  84. /// - callOptions: Call options.
  85. /// - handler: A closure called when each response is received from the server.
  86. /// - Returns: A `ServerStreamingCall` with futures for the metadata and status.
  87. public func listFeatures(
  88. _ request: Routeguide_Rectangle,
  89. callOptions: CallOptions? = nil,
  90. handler: @escaping (Routeguide_Feature) -> Void
  91. ) -> ServerStreamingCall<Routeguide_Rectangle, Routeguide_Feature> {
  92. return self.makeServerStreamingCall(
  93. path: Routeguide_RouteGuideClientMetadata.Methods.listFeatures.path,
  94. request: request,
  95. callOptions: callOptions ?? self.defaultCallOptions,
  96. interceptors: self.interceptors?.makeListFeaturesInterceptors() ?? [],
  97. handler: handler
  98. )
  99. }
  100. /// A client-to-server streaming RPC.
  101. ///
  102. /// Accepts a stream of Points on a route being traversed, returning a
  103. /// RouteSummary when traversal is completed.
  104. ///
  105. /// Callers should use the `send` method on the returned object to send messages
  106. /// to the server. The caller should send an `.end` after the final message has been sent.
  107. ///
  108. /// - Parameters:
  109. /// - callOptions: Call options.
  110. /// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response.
  111. public func recordRoute(
  112. callOptions: CallOptions? = nil
  113. ) -> ClientStreamingCall<Routeguide_Point, Routeguide_RouteSummary> {
  114. return self.makeClientStreamingCall(
  115. path: Routeguide_RouteGuideClientMetadata.Methods.recordRoute.path,
  116. callOptions: callOptions ?? self.defaultCallOptions,
  117. interceptors: self.interceptors?.makeRecordRouteInterceptors() ?? []
  118. )
  119. }
  120. /// A Bidirectional streaming RPC.
  121. ///
  122. /// Accepts a stream of RouteNotes sent while a route is being traversed,
  123. /// while receiving other RouteNotes (e.g. from other users).
  124. ///
  125. /// Callers should use the `send` method on the returned object to send messages
  126. /// to the server. The caller should send an `.end` after the final message has been sent.
  127. ///
  128. /// - Parameters:
  129. /// - callOptions: Call options.
  130. /// - handler: A closure called when each response is received from the server.
  131. /// - Returns: A `ClientStreamingCall` with futures for the metadata and status.
  132. public func routeChat(
  133. callOptions: CallOptions? = nil,
  134. handler: @escaping (Routeguide_RouteNote) -> Void
  135. ) -> BidirectionalStreamingCall<Routeguide_RouteNote, Routeguide_RouteNote> {
  136. return self.makeBidirectionalStreamingCall(
  137. path: Routeguide_RouteGuideClientMetadata.Methods.routeChat.path,
  138. callOptions: callOptions ?? self.defaultCallOptions,
  139. interceptors: self.interceptors?.makeRouteChatInterceptors() ?? [],
  140. handler: handler
  141. )
  142. }
  143. }
  144. @available(*, deprecated)
  145. extension Routeguide_RouteGuideClient: @unchecked Sendable {}
  146. @available(*, deprecated, renamed: "Routeguide_RouteGuideNIOClient")
  147. public final class Routeguide_RouteGuideClient: Routeguide_RouteGuideClientProtocol {
  148. private let lock = Lock()
  149. private var _defaultCallOptions: CallOptions
  150. private var _interceptors: Routeguide_RouteGuideClientInterceptorFactoryProtocol?
  151. public let channel: GRPCChannel
  152. public var defaultCallOptions: CallOptions {
  153. get { self.lock.withLock { return self._defaultCallOptions } }
  154. set { self.lock.withLockVoid { self._defaultCallOptions = newValue } }
  155. }
  156. public var interceptors: Routeguide_RouteGuideClientInterceptorFactoryProtocol? {
  157. get { self.lock.withLock { return self._interceptors } }
  158. set { self.lock.withLockVoid { self._interceptors = newValue } }
  159. }
  160. /// Creates a client for the routeguide.RouteGuide service.
  161. ///
  162. /// - Parameters:
  163. /// - channel: `GRPCChannel` to the service host.
  164. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  165. /// - interceptors: A factory providing interceptors for each RPC.
  166. public init(
  167. channel: GRPCChannel,
  168. defaultCallOptions: CallOptions = CallOptions(),
  169. interceptors: Routeguide_RouteGuideClientInterceptorFactoryProtocol? = nil
  170. ) {
  171. self.channel = channel
  172. self._defaultCallOptions = defaultCallOptions
  173. self._interceptors = interceptors
  174. }
  175. }
  176. public struct Routeguide_RouteGuideNIOClient: Routeguide_RouteGuideClientProtocol {
  177. public var channel: GRPCChannel
  178. public var defaultCallOptions: CallOptions
  179. public var interceptors: Routeguide_RouteGuideClientInterceptorFactoryProtocol?
  180. /// Creates a client for the routeguide.RouteGuide service.
  181. ///
  182. /// - Parameters:
  183. /// - channel: `GRPCChannel` to the service host.
  184. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  185. /// - interceptors: A factory providing interceptors for each RPC.
  186. public init(
  187. channel: GRPCChannel,
  188. defaultCallOptions: CallOptions = CallOptions(),
  189. interceptors: Routeguide_RouteGuideClientInterceptorFactoryProtocol? = nil
  190. ) {
  191. self.channel = channel
  192. self.defaultCallOptions = defaultCallOptions
  193. self.interceptors = interceptors
  194. }
  195. }
  196. /// Interface exported by the server.
  197. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  198. public protocol Routeguide_RouteGuideAsyncClientProtocol: GRPCClient {
  199. static var serviceDescriptor: GRPCServiceDescriptor { get }
  200. var interceptors: Routeguide_RouteGuideClientInterceptorFactoryProtocol? { get }
  201. func makeGetFeatureCall(
  202. _ request: Routeguide_Point,
  203. callOptions: CallOptions?
  204. ) -> GRPCAsyncUnaryCall<Routeguide_Point, Routeguide_Feature>
  205. func makeListFeaturesCall(
  206. _ request: Routeguide_Rectangle,
  207. callOptions: CallOptions?
  208. ) -> GRPCAsyncServerStreamingCall<Routeguide_Rectangle, Routeguide_Feature>
  209. func makeRecordRouteCall(
  210. callOptions: CallOptions?
  211. ) -> GRPCAsyncClientStreamingCall<Routeguide_Point, Routeguide_RouteSummary>
  212. func makeRouteChatCall(
  213. callOptions: CallOptions?
  214. ) -> GRPCAsyncBidirectionalStreamingCall<Routeguide_RouteNote, Routeguide_RouteNote>
  215. }
  216. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  217. extension Routeguide_RouteGuideAsyncClientProtocol {
  218. public static var serviceDescriptor: GRPCServiceDescriptor {
  219. return Routeguide_RouteGuideClientMetadata.serviceDescriptor
  220. }
  221. public var interceptors: Routeguide_RouteGuideClientInterceptorFactoryProtocol? {
  222. return nil
  223. }
  224. public func makeGetFeatureCall(
  225. _ request: Routeguide_Point,
  226. callOptions: CallOptions? = nil
  227. ) -> GRPCAsyncUnaryCall<Routeguide_Point, Routeguide_Feature> {
  228. return self.makeAsyncUnaryCall(
  229. path: Routeguide_RouteGuideClientMetadata.Methods.getFeature.path,
  230. request: request,
  231. callOptions: callOptions ?? self.defaultCallOptions,
  232. interceptors: self.interceptors?.makeGetFeatureInterceptors() ?? []
  233. )
  234. }
  235. public func makeListFeaturesCall(
  236. _ request: Routeguide_Rectangle,
  237. callOptions: CallOptions? = nil
  238. ) -> GRPCAsyncServerStreamingCall<Routeguide_Rectangle, Routeguide_Feature> {
  239. return self.makeAsyncServerStreamingCall(
  240. path: Routeguide_RouteGuideClientMetadata.Methods.listFeatures.path,
  241. request: request,
  242. callOptions: callOptions ?? self.defaultCallOptions,
  243. interceptors: self.interceptors?.makeListFeaturesInterceptors() ?? []
  244. )
  245. }
  246. public func makeRecordRouteCall(
  247. callOptions: CallOptions? = nil
  248. ) -> GRPCAsyncClientStreamingCall<Routeguide_Point, Routeguide_RouteSummary> {
  249. return self.makeAsyncClientStreamingCall(
  250. path: Routeguide_RouteGuideClientMetadata.Methods.recordRoute.path,
  251. callOptions: callOptions ?? self.defaultCallOptions,
  252. interceptors: self.interceptors?.makeRecordRouteInterceptors() ?? []
  253. )
  254. }
  255. public func makeRouteChatCall(
  256. callOptions: CallOptions? = nil
  257. ) -> GRPCAsyncBidirectionalStreamingCall<Routeguide_RouteNote, Routeguide_RouteNote> {
  258. return self.makeAsyncBidirectionalStreamingCall(
  259. path: Routeguide_RouteGuideClientMetadata.Methods.routeChat.path,
  260. callOptions: callOptions ?? self.defaultCallOptions,
  261. interceptors: self.interceptors?.makeRouteChatInterceptors() ?? []
  262. )
  263. }
  264. }
  265. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  266. extension Routeguide_RouteGuideAsyncClientProtocol {
  267. public func getFeature(
  268. _ request: Routeguide_Point,
  269. callOptions: CallOptions? = nil
  270. ) async throws -> Routeguide_Feature {
  271. return try await self.performAsyncUnaryCall(
  272. path: Routeguide_RouteGuideClientMetadata.Methods.getFeature.path,
  273. request: request,
  274. callOptions: callOptions ?? self.defaultCallOptions,
  275. interceptors: self.interceptors?.makeGetFeatureInterceptors() ?? []
  276. )
  277. }
  278. public func listFeatures(
  279. _ request: Routeguide_Rectangle,
  280. callOptions: CallOptions? = nil
  281. ) -> GRPCAsyncResponseStream<Routeguide_Feature> {
  282. return self.performAsyncServerStreamingCall(
  283. path: Routeguide_RouteGuideClientMetadata.Methods.listFeatures.path,
  284. request: request,
  285. callOptions: callOptions ?? self.defaultCallOptions,
  286. interceptors: self.interceptors?.makeListFeaturesInterceptors() ?? []
  287. )
  288. }
  289. public func recordRoute<RequestStream>(
  290. _ requests: RequestStream,
  291. callOptions: CallOptions? = nil
  292. ) async throws -> Routeguide_RouteSummary where RequestStream: Sequence, RequestStream.Element == Routeguide_Point {
  293. return try await self.performAsyncClientStreamingCall(
  294. path: Routeguide_RouteGuideClientMetadata.Methods.recordRoute.path,
  295. requests: requests,
  296. callOptions: callOptions ?? self.defaultCallOptions,
  297. interceptors: self.interceptors?.makeRecordRouteInterceptors() ?? []
  298. )
  299. }
  300. public func recordRoute<RequestStream>(
  301. _ requests: RequestStream,
  302. callOptions: CallOptions? = nil
  303. ) async throws -> Routeguide_RouteSummary where RequestStream: AsyncSequence & Sendable, RequestStream.Element == Routeguide_Point {
  304. return try await self.performAsyncClientStreamingCall(
  305. path: Routeguide_RouteGuideClientMetadata.Methods.recordRoute.path,
  306. requests: requests,
  307. callOptions: callOptions ?? self.defaultCallOptions,
  308. interceptors: self.interceptors?.makeRecordRouteInterceptors() ?? []
  309. )
  310. }
  311. public func routeChat<RequestStream>(
  312. _ requests: RequestStream,
  313. callOptions: CallOptions? = nil
  314. ) -> GRPCAsyncResponseStream<Routeguide_RouteNote> where RequestStream: Sequence, RequestStream.Element == Routeguide_RouteNote {
  315. return self.performAsyncBidirectionalStreamingCall(
  316. path: Routeguide_RouteGuideClientMetadata.Methods.routeChat.path,
  317. requests: requests,
  318. callOptions: callOptions ?? self.defaultCallOptions,
  319. interceptors: self.interceptors?.makeRouteChatInterceptors() ?? []
  320. )
  321. }
  322. public func routeChat<RequestStream>(
  323. _ requests: RequestStream,
  324. callOptions: CallOptions? = nil
  325. ) -> GRPCAsyncResponseStream<Routeguide_RouteNote> where RequestStream: AsyncSequence & Sendable, RequestStream.Element == Routeguide_RouteNote {
  326. return self.performAsyncBidirectionalStreamingCall(
  327. path: Routeguide_RouteGuideClientMetadata.Methods.routeChat.path,
  328. requests: requests,
  329. callOptions: callOptions ?? self.defaultCallOptions,
  330. interceptors: self.interceptors?.makeRouteChatInterceptors() ?? []
  331. )
  332. }
  333. }
  334. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  335. public struct Routeguide_RouteGuideAsyncClient: Routeguide_RouteGuideAsyncClientProtocol {
  336. public var channel: GRPCChannel
  337. public var defaultCallOptions: CallOptions
  338. public var interceptors: Routeguide_RouteGuideClientInterceptorFactoryProtocol?
  339. public init(
  340. channel: GRPCChannel,
  341. defaultCallOptions: CallOptions = CallOptions(),
  342. interceptors: Routeguide_RouteGuideClientInterceptorFactoryProtocol? = nil
  343. ) {
  344. self.channel = channel
  345. self.defaultCallOptions = defaultCallOptions
  346. self.interceptors = interceptors
  347. }
  348. }
  349. public protocol Routeguide_RouteGuideClientInterceptorFactoryProtocol: Sendable {
  350. /// - Returns: Interceptors to use when invoking 'getFeature'.
  351. func makeGetFeatureInterceptors() -> [ClientInterceptor<Routeguide_Point, Routeguide_Feature>]
  352. /// - Returns: Interceptors to use when invoking 'listFeatures'.
  353. func makeListFeaturesInterceptors() -> [ClientInterceptor<Routeguide_Rectangle, Routeguide_Feature>]
  354. /// - Returns: Interceptors to use when invoking 'recordRoute'.
  355. func makeRecordRouteInterceptors() -> [ClientInterceptor<Routeguide_Point, Routeguide_RouteSummary>]
  356. /// - Returns: Interceptors to use when invoking 'routeChat'.
  357. func makeRouteChatInterceptors() -> [ClientInterceptor<Routeguide_RouteNote, Routeguide_RouteNote>]
  358. }
  359. public enum Routeguide_RouteGuideClientMetadata {
  360. public static let serviceDescriptor = GRPCServiceDescriptor(
  361. name: "RouteGuide",
  362. fullName: "routeguide.RouteGuide",
  363. methods: [
  364. Routeguide_RouteGuideClientMetadata.Methods.getFeature,
  365. Routeguide_RouteGuideClientMetadata.Methods.listFeatures,
  366. Routeguide_RouteGuideClientMetadata.Methods.recordRoute,
  367. Routeguide_RouteGuideClientMetadata.Methods.routeChat,
  368. ]
  369. )
  370. public enum Methods {
  371. public static let getFeature = GRPCMethodDescriptor(
  372. name: "GetFeature",
  373. path: "/routeguide.RouteGuide/GetFeature",
  374. type: GRPCCallType.unary
  375. )
  376. public static let listFeatures = GRPCMethodDescriptor(
  377. name: "ListFeatures",
  378. path: "/routeguide.RouteGuide/ListFeatures",
  379. type: GRPCCallType.serverStreaming
  380. )
  381. public static let recordRoute = GRPCMethodDescriptor(
  382. name: "RecordRoute",
  383. path: "/routeguide.RouteGuide/RecordRoute",
  384. type: GRPCCallType.clientStreaming
  385. )
  386. public static let routeChat = GRPCMethodDescriptor(
  387. name: "RouteChat",
  388. path: "/routeguide.RouteGuide/RouteChat",
  389. type: GRPCCallType.bidirectionalStreaming
  390. )
  391. }
  392. }
  393. /// Interface exported by the server.
  394. ///
  395. /// To build a server, implement a class that conforms to this protocol.
  396. public protocol Routeguide_RouteGuideProvider: CallHandlerProvider {
  397. var interceptors: Routeguide_RouteGuideServerInterceptorFactoryProtocol? { get }
  398. /// A simple RPC.
  399. ///
  400. /// Obtains the feature at a given position.
  401. ///
  402. /// A feature with an empty name is returned if there's no feature at the given
  403. /// position.
  404. func getFeature(request: Routeguide_Point, context: StatusOnlyCallContext) -> EventLoopFuture<Routeguide_Feature>
  405. /// A server-to-client streaming RPC.
  406. ///
  407. /// Obtains the Features available within the given Rectangle. Results are
  408. /// streamed rather than returned at once (e.g. in a response message with a
  409. /// repeated field), as the rectangle may cover a large area and contain a
  410. /// huge number of features.
  411. func listFeatures(request: Routeguide_Rectangle, context: StreamingResponseCallContext<Routeguide_Feature>) -> EventLoopFuture<GRPCStatus>
  412. /// A client-to-server streaming RPC.
  413. ///
  414. /// Accepts a stream of Points on a route being traversed, returning a
  415. /// RouteSummary when traversal is completed.
  416. func recordRoute(context: UnaryResponseCallContext<Routeguide_RouteSummary>) -> EventLoopFuture<(StreamEvent<Routeguide_Point>) -> Void>
  417. /// A Bidirectional streaming RPC.
  418. ///
  419. /// Accepts a stream of RouteNotes sent while a route is being traversed,
  420. /// while receiving other RouteNotes (e.g. from other users).
  421. func routeChat(context: StreamingResponseCallContext<Routeguide_RouteNote>) -> EventLoopFuture<(StreamEvent<Routeguide_RouteNote>) -> Void>
  422. }
  423. extension Routeguide_RouteGuideProvider {
  424. public var serviceName: Substring {
  425. return Routeguide_RouteGuideServerMetadata.serviceDescriptor.fullName[...]
  426. }
  427. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  428. /// Returns nil for methods not handled by this service.
  429. public func handle(
  430. method name: Substring,
  431. context: CallHandlerContext
  432. ) -> GRPCServerHandlerProtocol? {
  433. switch name {
  434. case "GetFeature":
  435. return UnaryServerHandler(
  436. context: context,
  437. requestDeserializer: ProtobufDeserializer<Routeguide_Point>(),
  438. responseSerializer: ProtobufSerializer<Routeguide_Feature>(),
  439. interceptors: self.interceptors?.makeGetFeatureInterceptors() ?? [],
  440. userFunction: self.getFeature(request:context:)
  441. )
  442. case "ListFeatures":
  443. return ServerStreamingServerHandler(
  444. context: context,
  445. requestDeserializer: ProtobufDeserializer<Routeguide_Rectangle>(),
  446. responseSerializer: ProtobufSerializer<Routeguide_Feature>(),
  447. interceptors: self.interceptors?.makeListFeaturesInterceptors() ?? [],
  448. userFunction: self.listFeatures(request:context:)
  449. )
  450. case "RecordRoute":
  451. return ClientStreamingServerHandler(
  452. context: context,
  453. requestDeserializer: ProtobufDeserializer<Routeguide_Point>(),
  454. responseSerializer: ProtobufSerializer<Routeguide_RouteSummary>(),
  455. interceptors: self.interceptors?.makeRecordRouteInterceptors() ?? [],
  456. observerFactory: self.recordRoute(context:)
  457. )
  458. case "RouteChat":
  459. return BidirectionalStreamingServerHandler(
  460. context: context,
  461. requestDeserializer: ProtobufDeserializer<Routeguide_RouteNote>(),
  462. responseSerializer: ProtobufSerializer<Routeguide_RouteNote>(),
  463. interceptors: self.interceptors?.makeRouteChatInterceptors() ?? [],
  464. observerFactory: self.routeChat(context:)
  465. )
  466. default:
  467. return nil
  468. }
  469. }
  470. }
  471. /// Interface exported by the server.
  472. ///
  473. /// To implement a server, implement an object which conforms to this protocol.
  474. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  475. public protocol Routeguide_RouteGuideAsyncProvider: CallHandlerProvider {
  476. static var serviceDescriptor: GRPCServiceDescriptor { get }
  477. var interceptors: Routeguide_RouteGuideServerInterceptorFactoryProtocol? { get }
  478. /// A simple RPC.
  479. ///
  480. /// Obtains the feature at a given position.
  481. ///
  482. /// A feature with an empty name is returned if there's no feature at the given
  483. /// position.
  484. @Sendable func getFeature(
  485. request: Routeguide_Point,
  486. context: GRPCAsyncServerCallContext
  487. ) async throws -> Routeguide_Feature
  488. /// A server-to-client streaming RPC.
  489. ///
  490. /// Obtains the Features available within the given Rectangle. Results are
  491. /// streamed rather than returned at once (e.g. in a response message with a
  492. /// repeated field), as the rectangle may cover a large area and contain a
  493. /// huge number of features.
  494. @Sendable func listFeatures(
  495. request: Routeguide_Rectangle,
  496. responseStream: GRPCAsyncResponseStreamWriter<Routeguide_Feature>,
  497. context: GRPCAsyncServerCallContext
  498. ) async throws
  499. /// A client-to-server streaming RPC.
  500. ///
  501. /// Accepts a stream of Points on a route being traversed, returning a
  502. /// RouteSummary when traversal is completed.
  503. @Sendable func recordRoute(
  504. requestStream: GRPCAsyncRequestStream<Routeguide_Point>,
  505. context: GRPCAsyncServerCallContext
  506. ) async throws -> Routeguide_RouteSummary
  507. /// A Bidirectional streaming RPC.
  508. ///
  509. /// Accepts a stream of RouteNotes sent while a route is being traversed,
  510. /// while receiving other RouteNotes (e.g. from other users).
  511. @Sendable func routeChat(
  512. requestStream: GRPCAsyncRequestStream<Routeguide_RouteNote>,
  513. responseStream: GRPCAsyncResponseStreamWriter<Routeguide_RouteNote>,
  514. context: GRPCAsyncServerCallContext
  515. ) async throws
  516. }
  517. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  518. extension Routeguide_RouteGuideAsyncProvider {
  519. public static var serviceDescriptor: GRPCServiceDescriptor {
  520. return Routeguide_RouteGuideServerMetadata.serviceDescriptor
  521. }
  522. public var serviceName: Substring {
  523. return Routeguide_RouteGuideServerMetadata.serviceDescriptor.fullName[...]
  524. }
  525. public var interceptors: Routeguide_RouteGuideServerInterceptorFactoryProtocol? {
  526. return nil
  527. }
  528. public func handle(
  529. method name: Substring,
  530. context: CallHandlerContext
  531. ) -> GRPCServerHandlerProtocol? {
  532. switch name {
  533. case "GetFeature":
  534. return GRPCAsyncServerHandler(
  535. context: context,
  536. requestDeserializer: ProtobufDeserializer<Routeguide_Point>(),
  537. responseSerializer: ProtobufSerializer<Routeguide_Feature>(),
  538. interceptors: self.interceptors?.makeGetFeatureInterceptors() ?? [],
  539. wrapping: self.getFeature(request:context:)
  540. )
  541. case "ListFeatures":
  542. return GRPCAsyncServerHandler(
  543. context: context,
  544. requestDeserializer: ProtobufDeserializer<Routeguide_Rectangle>(),
  545. responseSerializer: ProtobufSerializer<Routeguide_Feature>(),
  546. interceptors: self.interceptors?.makeListFeaturesInterceptors() ?? [],
  547. wrapping: self.listFeatures(request:responseStream:context:)
  548. )
  549. case "RecordRoute":
  550. return GRPCAsyncServerHandler(
  551. context: context,
  552. requestDeserializer: ProtobufDeserializer<Routeguide_Point>(),
  553. responseSerializer: ProtobufSerializer<Routeguide_RouteSummary>(),
  554. interceptors: self.interceptors?.makeRecordRouteInterceptors() ?? [],
  555. wrapping: self.recordRoute(requestStream:context:)
  556. )
  557. case "RouteChat":
  558. return GRPCAsyncServerHandler(
  559. context: context,
  560. requestDeserializer: ProtobufDeserializer<Routeguide_RouteNote>(),
  561. responseSerializer: ProtobufSerializer<Routeguide_RouteNote>(),
  562. interceptors: self.interceptors?.makeRouteChatInterceptors() ?? [],
  563. wrapping: self.routeChat(requestStream:responseStream:context:)
  564. )
  565. default:
  566. return nil
  567. }
  568. }
  569. }
  570. public protocol Routeguide_RouteGuideServerInterceptorFactoryProtocol {
  571. /// - Returns: Interceptors to use when handling 'getFeature'.
  572. /// Defaults to calling `self.makeInterceptors()`.
  573. func makeGetFeatureInterceptors() -> [ServerInterceptor<Routeguide_Point, Routeguide_Feature>]
  574. /// - Returns: Interceptors to use when handling 'listFeatures'.
  575. /// Defaults to calling `self.makeInterceptors()`.
  576. func makeListFeaturesInterceptors() -> [ServerInterceptor<Routeguide_Rectangle, Routeguide_Feature>]
  577. /// - Returns: Interceptors to use when handling 'recordRoute'.
  578. /// Defaults to calling `self.makeInterceptors()`.
  579. func makeRecordRouteInterceptors() -> [ServerInterceptor<Routeguide_Point, Routeguide_RouteSummary>]
  580. /// - Returns: Interceptors to use when handling 'routeChat'.
  581. /// Defaults to calling `self.makeInterceptors()`.
  582. func makeRouteChatInterceptors() -> [ServerInterceptor<Routeguide_RouteNote, Routeguide_RouteNote>]
  583. }
  584. public enum Routeguide_RouteGuideServerMetadata {
  585. public static let serviceDescriptor = GRPCServiceDescriptor(
  586. name: "RouteGuide",
  587. fullName: "routeguide.RouteGuide",
  588. methods: [
  589. Routeguide_RouteGuideServerMetadata.Methods.getFeature,
  590. Routeguide_RouteGuideServerMetadata.Methods.listFeatures,
  591. Routeguide_RouteGuideServerMetadata.Methods.recordRoute,
  592. Routeguide_RouteGuideServerMetadata.Methods.routeChat,
  593. ]
  594. )
  595. public enum Methods {
  596. public static let getFeature = GRPCMethodDescriptor(
  597. name: "GetFeature",
  598. path: "/routeguide.RouteGuide/GetFeature",
  599. type: GRPCCallType.unary
  600. )
  601. public static let listFeatures = GRPCMethodDescriptor(
  602. name: "ListFeatures",
  603. path: "/routeguide.RouteGuide/ListFeatures",
  604. type: GRPCCallType.serverStreaming
  605. )
  606. public static let recordRoute = GRPCMethodDescriptor(
  607. name: "RecordRoute",
  608. path: "/routeguide.RouteGuide/RecordRoute",
  609. type: GRPCCallType.clientStreaming
  610. )
  611. public static let routeChat = GRPCMethodDescriptor(
  612. name: "RouteChat",
  613. path: "/routeguide.RouteGuide/RouteChat",
  614. type: GRPCCallType.bidirectionalStreaming
  615. )
  616. }
  617. }