route_guide.grpc.swift 25 KB

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