health.grpc.swift 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. // Copyright 2015 The gRPC Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // The canonical version of this proto can be found at
  15. // https://github.com/grpc/grpc-proto/blob/master/grpc/health/v1/health.proto
  16. // DO NOT EDIT.
  17. // swift-format-ignore-file
  18. //
  19. // Generated by the gRPC Swift generator plugin for the protocol buffer compiler.
  20. // Source: health.proto
  21. //
  22. // For information on using the generated types, please see the documentation:
  23. // https://github.com/grpc/grpc-swift
  24. package import GRPCCore
  25. internal import GRPCProtobuf
  26. package enum Grpc_Health_V1_Health {
  27. package static let descriptor = GRPCCore.ServiceDescriptor.grpc_health_v1_Health
  28. package enum Method {
  29. package enum Check {
  30. package typealias Input = Grpc_Health_V1_HealthCheckRequest
  31. package typealias Output = Grpc_Health_V1_HealthCheckResponse
  32. package static let descriptor = GRPCCore.MethodDescriptor(
  33. service: Grpc_Health_V1_Health.descriptor.fullyQualifiedService,
  34. method: "Check"
  35. )
  36. }
  37. package enum Watch {
  38. package typealias Input = Grpc_Health_V1_HealthCheckRequest
  39. package typealias Output = Grpc_Health_V1_HealthCheckResponse
  40. package static let descriptor = GRPCCore.MethodDescriptor(
  41. service: Grpc_Health_V1_Health.descriptor.fullyQualifiedService,
  42. method: "Watch"
  43. )
  44. }
  45. package static let descriptors: [GRPCCore.MethodDescriptor] = [
  46. Check.descriptor,
  47. Watch.descriptor
  48. ]
  49. }
  50. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  51. package typealias StreamingServiceProtocol = Grpc_Health_V1_HealthStreamingServiceProtocol
  52. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  53. package typealias ServiceProtocol = Grpc_Health_V1_HealthServiceProtocol
  54. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  55. package typealias ClientProtocol = Grpc_Health_V1_HealthClientProtocol
  56. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  57. package typealias Client = Grpc_Health_V1_HealthClient
  58. }
  59. extension GRPCCore.ServiceDescriptor {
  60. package static let grpc_health_v1_Health = Self(
  61. package: "grpc.health.v1",
  62. service: "Health"
  63. )
  64. }
  65. /// Health is gRPC's mechanism for checking whether a server is able to handle
  66. /// RPCs. Its semantics are documented in
  67. /// https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
  68. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  69. package protocol Grpc_Health_V1_HealthStreamingServiceProtocol: GRPCCore.RegistrableRPCService {
  70. /// Check gets the health of the specified service. If the requested service
  71. /// is unknown, the call will fail with status NOT_FOUND. If the caller does
  72. /// not specify a service name, the server should respond with its overall
  73. /// health status.
  74. ///
  75. /// Clients should set a deadline when calling Check, and can declare the
  76. /// server unhealthy if they do not receive a timely response.
  77. ///
  78. /// Check implementations should be idempotent and side effect free.
  79. func check(
  80. request: GRPCCore.ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>,
  81. context: GRPCCore.ServerContext
  82. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse>
  83. /// Performs a watch for the serving status of the requested service.
  84. /// The server will immediately send back a message indicating the current
  85. /// serving status. It will then subsequently send a new message whenever
  86. /// the service's serving status changes.
  87. ///
  88. /// If the requested service is unknown when the call is received, the
  89. /// server will send a message setting the serving status to
  90. /// SERVICE_UNKNOWN but will *not* terminate the call. If at some
  91. /// future point, the serving status of the service becomes known, the
  92. /// server will send a new message with the service's serving status.
  93. ///
  94. /// If the call terminates with status UNIMPLEMENTED, then clients
  95. /// should assume this method is not supported and should not retry the
  96. /// call. If the call terminates with any other status (including OK),
  97. /// clients should retry the call with appropriate exponential backoff.
  98. func watch(
  99. request: GRPCCore.ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>,
  100. context: GRPCCore.ServerContext
  101. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse>
  102. }
  103. /// Conformance to `GRPCCore.RegistrableRPCService`.
  104. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  105. extension Grpc_Health_V1_Health.StreamingServiceProtocol {
  106. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  107. package func registerMethods(with router: inout GRPCCore.RPCRouter) {
  108. router.registerHandler(
  109. forMethod: Grpc_Health_V1_Health.Method.Check.descriptor,
  110. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Health_V1_HealthCheckRequest>(),
  111. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Health_V1_HealthCheckResponse>(),
  112. handler: { request, context in
  113. try await self.check(
  114. request: request,
  115. context: context
  116. )
  117. }
  118. )
  119. router.registerHandler(
  120. forMethod: Grpc_Health_V1_Health.Method.Watch.descriptor,
  121. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Health_V1_HealthCheckRequest>(),
  122. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Health_V1_HealthCheckResponse>(),
  123. handler: { request, context in
  124. try await self.watch(
  125. request: request,
  126. context: context
  127. )
  128. }
  129. )
  130. }
  131. }
  132. /// Health is gRPC's mechanism for checking whether a server is able to handle
  133. /// RPCs. Its semantics are documented in
  134. /// https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
  135. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  136. package protocol Grpc_Health_V1_HealthServiceProtocol: Grpc_Health_V1_Health.StreamingServiceProtocol {
  137. /// Check gets the health of the specified service. If the requested service
  138. /// is unknown, the call will fail with status NOT_FOUND. If the caller does
  139. /// not specify a service name, the server should respond with its overall
  140. /// health status.
  141. ///
  142. /// Clients should set a deadline when calling Check, and can declare the
  143. /// server unhealthy if they do not receive a timely response.
  144. ///
  145. /// Check implementations should be idempotent and side effect free.
  146. func check(
  147. request: GRPCCore.ServerRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  148. context: GRPCCore.ServerContext
  149. ) async throws -> GRPCCore.ServerResponse.Single<Grpc_Health_V1_HealthCheckResponse>
  150. /// Performs a watch for the serving status of the requested service.
  151. /// The server will immediately send back a message indicating the current
  152. /// serving status. It will then subsequently send a new message whenever
  153. /// the service's serving status changes.
  154. ///
  155. /// If the requested service is unknown when the call is received, the
  156. /// server will send a message setting the serving status to
  157. /// SERVICE_UNKNOWN but will *not* terminate the call. If at some
  158. /// future point, the serving status of the service becomes known, the
  159. /// server will send a new message with the service's serving status.
  160. ///
  161. /// If the call terminates with status UNIMPLEMENTED, then clients
  162. /// should assume this method is not supported and should not retry the
  163. /// call. If the call terminates with any other status (including OK),
  164. /// clients should retry the call with appropriate exponential backoff.
  165. func watch(
  166. request: GRPCCore.ServerRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  167. context: GRPCCore.ServerContext
  168. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse>
  169. }
  170. /// Partial conformance to `Grpc_Health_V1_HealthStreamingServiceProtocol`.
  171. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  172. extension Grpc_Health_V1_Health.ServiceProtocol {
  173. package func check(
  174. request: GRPCCore.ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>,
  175. context: GRPCCore.ServerContext
  176. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse> {
  177. let response = try await self.check(
  178. request: GRPCCore.ServerRequest.Single(stream: request),
  179. context: context
  180. )
  181. return GRPCCore.ServerResponse.Stream(single: response)
  182. }
  183. package func watch(
  184. request: GRPCCore.ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>,
  185. context: GRPCCore.ServerContext
  186. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse> {
  187. let response = try await self.watch(
  188. request: GRPCCore.ServerRequest.Single(stream: request),
  189. context: context
  190. )
  191. return response
  192. }
  193. }
  194. /// Health is gRPC's mechanism for checking whether a server is able to handle
  195. /// RPCs. Its semantics are documented in
  196. /// https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
  197. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  198. package protocol Grpc_Health_V1_HealthClientProtocol: Sendable {
  199. /// Check gets the health of the specified service. If the requested service
  200. /// is unknown, the call will fail with status NOT_FOUND. If the caller does
  201. /// not specify a service name, the server should respond with its overall
  202. /// health status.
  203. ///
  204. /// Clients should set a deadline when calling Check, and can declare the
  205. /// server unhealthy if they do not receive a timely response.
  206. ///
  207. /// Check implementations should be idempotent and side effect free.
  208. func check<R>(
  209. request: GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  210. serializer: some GRPCCore.MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
  211. deserializer: some GRPCCore.MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
  212. options: GRPCCore.CallOptions,
  213. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
  214. ) async throws -> R where R: Sendable
  215. /// Performs a watch for the serving status of the requested service.
  216. /// The server will immediately send back a message indicating the current
  217. /// serving status. It will then subsequently send a new message whenever
  218. /// the service's serving status changes.
  219. ///
  220. /// If the requested service is unknown when the call is received, the
  221. /// server will send a message setting the serving status to
  222. /// SERVICE_UNKNOWN but will *not* terminate the call. If at some
  223. /// future point, the serving status of the service becomes known, the
  224. /// server will send a new message with the service's serving status.
  225. ///
  226. /// If the call terminates with status UNIMPLEMENTED, then clients
  227. /// should assume this method is not supported and should not retry the
  228. /// call. If the call terminates with any other status (including OK),
  229. /// clients should retry the call with appropriate exponential backoff.
  230. func watch<R>(
  231. request: GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  232. serializer: some GRPCCore.MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
  233. deserializer: some GRPCCore.MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
  234. options: GRPCCore.CallOptions,
  235. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
  236. ) async throws -> R where R: Sendable
  237. }
  238. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  239. extension Grpc_Health_V1_Health.ClientProtocol {
  240. package func check<R>(
  241. request: GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  242. options: GRPCCore.CallOptions = .defaults,
  243. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Health_V1_HealthCheckResponse>) async throws -> R = {
  244. try $0.message
  245. }
  246. ) async throws -> R where R: Sendable {
  247. try await self.check(
  248. request: request,
  249. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Health_V1_HealthCheckRequest>(),
  250. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Health_V1_HealthCheckResponse>(),
  251. options: options,
  252. body
  253. )
  254. }
  255. package func watch<R>(
  256. request: GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  257. options: GRPCCore.CallOptions = .defaults,
  258. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
  259. ) async throws -> R where R: Sendable {
  260. try await self.watch(
  261. request: request,
  262. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Health_V1_HealthCheckRequest>(),
  263. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Health_V1_HealthCheckResponse>(),
  264. options: options,
  265. body
  266. )
  267. }
  268. }
  269. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  270. extension Grpc_Health_V1_Health.ClientProtocol {
  271. /// Check gets the health of the specified service. If the requested service
  272. /// is unknown, the call will fail with status NOT_FOUND. If the caller does
  273. /// not specify a service name, the server should respond with its overall
  274. /// health status.
  275. ///
  276. /// Clients should set a deadline when calling Check, and can declare the
  277. /// server unhealthy if they do not receive a timely response.
  278. ///
  279. /// Check implementations should be idempotent and side effect free.
  280. package func check<Result>(
  281. _ message: Grpc_Health_V1_HealthCheckRequest,
  282. metadata: GRPCCore.Metadata = [:],
  283. options: GRPCCore.CallOptions = .defaults,
  284. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Health_V1_HealthCheckResponse>) async throws -> Result = {
  285. try $0.message
  286. }
  287. ) async throws -> Result where Result: Sendable {
  288. let request = GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>(
  289. message: message,
  290. metadata: metadata
  291. )
  292. return try await self.check(
  293. request: request,
  294. options: options,
  295. handleResponse
  296. )
  297. }
  298. /// Performs a watch for the serving status of the requested service.
  299. /// The server will immediately send back a message indicating the current
  300. /// serving status. It will then subsequently send a new message whenever
  301. /// the service's serving status changes.
  302. ///
  303. /// If the requested service is unknown when the call is received, the
  304. /// server will send a message setting the serving status to
  305. /// SERVICE_UNKNOWN but will *not* terminate the call. If at some
  306. /// future point, the serving status of the service becomes known, the
  307. /// server will send a new message with the service's serving status.
  308. ///
  309. /// If the call terminates with status UNIMPLEMENTED, then clients
  310. /// should assume this method is not supported and should not retry the
  311. /// call. If the call terminates with any other status (including OK),
  312. /// clients should retry the call with appropriate exponential backoff.
  313. package func watch<Result>(
  314. _ message: Grpc_Health_V1_HealthCheckRequest,
  315. metadata: GRPCCore.Metadata = [:],
  316. options: GRPCCore.CallOptions = .defaults,
  317. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Health_V1_HealthCheckResponse>) async throws -> Result
  318. ) async throws -> Result where Result: Sendable {
  319. let request = GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>(
  320. message: message,
  321. metadata: metadata
  322. )
  323. return try await self.watch(
  324. request: request,
  325. options: options,
  326. handleResponse
  327. )
  328. }
  329. }
  330. /// Health is gRPC's mechanism for checking whether a server is able to handle
  331. /// RPCs. Its semantics are documented in
  332. /// https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
  333. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  334. package struct Grpc_Health_V1_HealthClient: Grpc_Health_V1_Health.ClientProtocol {
  335. private let client: GRPCCore.GRPCClient
  336. package init(wrapping client: GRPCCore.GRPCClient) {
  337. self.client = client
  338. }
  339. /// Check gets the health of the specified service. If the requested service
  340. /// is unknown, the call will fail with status NOT_FOUND. If the caller does
  341. /// not specify a service name, the server should respond with its overall
  342. /// health status.
  343. ///
  344. /// Clients should set a deadline when calling Check, and can declare the
  345. /// server unhealthy if they do not receive a timely response.
  346. ///
  347. /// Check implementations should be idempotent and side effect free.
  348. package func check<R>(
  349. request: GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  350. serializer: some GRPCCore.MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
  351. deserializer: some GRPCCore.MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
  352. options: GRPCCore.CallOptions = .defaults,
  353. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Health_V1_HealthCheckResponse>) async throws -> R = {
  354. try $0.message
  355. }
  356. ) async throws -> R where R: Sendable {
  357. try await self.client.unary(
  358. request: request,
  359. descriptor: Grpc_Health_V1_Health.Method.Check.descriptor,
  360. serializer: serializer,
  361. deserializer: deserializer,
  362. options: options,
  363. handler: body
  364. )
  365. }
  366. /// Performs a watch for the serving status of the requested service.
  367. /// The server will immediately send back a message indicating the current
  368. /// serving status. It will then subsequently send a new message whenever
  369. /// the service's serving status changes.
  370. ///
  371. /// If the requested service is unknown when the call is received, the
  372. /// server will send a message setting the serving status to
  373. /// SERVICE_UNKNOWN but will *not* terminate the call. If at some
  374. /// future point, the serving status of the service becomes known, the
  375. /// server will send a new message with the service's serving status.
  376. ///
  377. /// If the call terminates with status UNIMPLEMENTED, then clients
  378. /// should assume this method is not supported and should not retry the
  379. /// call. If the call terminates with any other status (including OK),
  380. /// clients should retry the call with appropriate exponential backoff.
  381. package func watch<R>(
  382. request: GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  383. serializer: some GRPCCore.MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
  384. deserializer: some GRPCCore.MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
  385. options: GRPCCore.CallOptions = .defaults,
  386. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
  387. ) async throws -> R where R: Sendable {
  388. try await self.client.serverStreaming(
  389. request: request,
  390. descriptor: Grpc_Health_V1_Health.Method.Watch.descriptor,
  391. serializer: serializer,
  392. deserializer: deserializer,
  393. options: options,
  394. handler: body
  395. )
  396. }
  397. }