route_guide.grpc.swift 26 KB

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