health.grpc.swift 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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(request: GRPCCore.ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse>
  80. /// Performs a watch for the serving status of the requested service.
  81. /// The server will immediately send back a message indicating the current
  82. /// serving status. It will then subsequently send a new message whenever
  83. /// the service's serving status changes.
  84. ///
  85. /// If the requested service is unknown when the call is received, the
  86. /// server will send a message setting the serving status to
  87. /// SERVICE_UNKNOWN but will *not* terminate the call. If at some
  88. /// future point, the serving status of the service becomes known, the
  89. /// server will send a new message with the service's serving status.
  90. ///
  91. /// If the call terminates with status UNIMPLEMENTED, then clients
  92. /// should assume this method is not supported and should not retry the
  93. /// call. If the call terminates with any other status (including OK),
  94. /// clients should retry the call with appropriate exponential backoff.
  95. func watch(request: GRPCCore.ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse>
  96. }
  97. /// Conformance to `GRPCCore.RegistrableRPCService`.
  98. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  99. extension Grpc_Health_V1_Health.StreamingServiceProtocol {
  100. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  101. package func registerMethods(with router: inout GRPCCore.RPCRouter) {
  102. router.registerHandler(
  103. forMethod: Grpc_Health_V1_Health.Method.Check.descriptor,
  104. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Health_V1_HealthCheckRequest>(),
  105. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Health_V1_HealthCheckResponse>(),
  106. handler: { request in
  107. try await self.check(request: request)
  108. }
  109. )
  110. router.registerHandler(
  111. forMethod: Grpc_Health_V1_Health.Method.Watch.descriptor,
  112. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Health_V1_HealthCheckRequest>(),
  113. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Health_V1_HealthCheckResponse>(),
  114. handler: { request in
  115. try await self.watch(request: request)
  116. }
  117. )
  118. }
  119. }
  120. /// Health is gRPC's mechanism for checking whether a server is able to handle
  121. /// RPCs. Its semantics are documented in
  122. /// https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
  123. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  124. package protocol Grpc_Health_V1_HealthServiceProtocol: Grpc_Health_V1_Health.StreamingServiceProtocol {
  125. /// Check gets the health of the specified service. If the requested service
  126. /// is unknown, the call will fail with status NOT_FOUND. If the caller does
  127. /// not specify a service name, the server should respond with its overall
  128. /// health status.
  129. ///
  130. /// Clients should set a deadline when calling Check, and can declare the
  131. /// server unhealthy if they do not receive a timely response.
  132. ///
  133. /// Check implementations should be idempotent and side effect free.
  134. func check(request: GRPCCore.ServerRequest.Single<Grpc_Health_V1_HealthCheckRequest>) async throws -> GRPCCore.ServerResponse.Single<Grpc_Health_V1_HealthCheckResponse>
  135. /// Performs a watch for the serving status of the requested service.
  136. /// The server will immediately send back a message indicating the current
  137. /// serving status. It will then subsequently send a new message whenever
  138. /// the service's serving status changes.
  139. ///
  140. /// If the requested service is unknown when the call is received, the
  141. /// server will send a message setting the serving status to
  142. /// SERVICE_UNKNOWN but will *not* terminate the call. If at some
  143. /// future point, the serving status of the service becomes known, the
  144. /// server will send a new message with the service's serving status.
  145. ///
  146. /// If the call terminates with status UNIMPLEMENTED, then clients
  147. /// should assume this method is not supported and should not retry the
  148. /// call. If the call terminates with any other status (including OK),
  149. /// clients should retry the call with appropriate exponential backoff.
  150. func watch(request: GRPCCore.ServerRequest.Single<Grpc_Health_V1_HealthCheckRequest>) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse>
  151. }
  152. /// Partial conformance to `Grpc_Health_V1_HealthStreamingServiceProtocol`.
  153. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  154. extension Grpc_Health_V1_Health.ServiceProtocol {
  155. package func check(request: GRPCCore.ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse> {
  156. let response = try await self.check(request: GRPCCore.ServerRequest.Single(stream: request))
  157. return GRPCCore.ServerResponse.Stream(single: response)
  158. }
  159. package func watch(request: GRPCCore.ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse> {
  160. let response = try await self.watch(request: GRPCCore.ServerRequest.Single(stream: request))
  161. return response
  162. }
  163. }
  164. /// Health is gRPC's mechanism for checking whether a server is able to handle
  165. /// RPCs. Its semantics are documented in
  166. /// https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
  167. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  168. package protocol Grpc_Health_V1_HealthClientProtocol: Sendable {
  169. /// Check gets the health of the specified service. If the requested service
  170. /// is unknown, the call will fail with status NOT_FOUND. If the caller does
  171. /// not specify a service name, the server should respond with its overall
  172. /// health status.
  173. ///
  174. /// Clients should set a deadline when calling Check, and can declare the
  175. /// server unhealthy if they do not receive a timely response.
  176. ///
  177. /// Check implementations should be idempotent and side effect free.
  178. func check<R>(
  179. request: GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  180. serializer: some GRPCCore.MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
  181. deserializer: some GRPCCore.MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
  182. options: GRPCCore.CallOptions,
  183. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
  184. ) async throws -> R where R: Sendable
  185. /// Performs a watch for the serving status of the requested service.
  186. /// The server will immediately send back a message indicating the current
  187. /// serving status. It will then subsequently send a new message whenever
  188. /// the service's serving status changes.
  189. ///
  190. /// If the requested service is unknown when the call is received, the
  191. /// server will send a message setting the serving status to
  192. /// SERVICE_UNKNOWN but will *not* terminate the call. If at some
  193. /// future point, the serving status of the service becomes known, the
  194. /// server will send a new message with the service's serving status.
  195. ///
  196. /// If the call terminates with status UNIMPLEMENTED, then clients
  197. /// should assume this method is not supported and should not retry the
  198. /// call. If the call terminates with any other status (including OK),
  199. /// clients should retry the call with appropriate exponential backoff.
  200. func watch<R>(
  201. request: GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  202. serializer: some GRPCCore.MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
  203. deserializer: some GRPCCore.MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
  204. options: GRPCCore.CallOptions,
  205. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
  206. ) async throws -> R where R: Sendable
  207. }
  208. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  209. extension Grpc_Health_V1_Health.ClientProtocol {
  210. package func check<R>(
  211. request: GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  212. options: GRPCCore.CallOptions = .defaults,
  213. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Health_V1_HealthCheckResponse>) async throws -> R = {
  214. try $0.message
  215. }
  216. ) async throws -> R where R: Sendable {
  217. try await self.check(
  218. request: request,
  219. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Health_V1_HealthCheckRequest>(),
  220. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Health_V1_HealthCheckResponse>(),
  221. options: options,
  222. body
  223. )
  224. }
  225. package func watch<R>(
  226. request: GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  227. options: GRPCCore.CallOptions = .defaults,
  228. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
  229. ) async throws -> R where R: Sendable {
  230. try await self.watch(
  231. request: request,
  232. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Health_V1_HealthCheckRequest>(),
  233. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Health_V1_HealthCheckResponse>(),
  234. options: options,
  235. body
  236. )
  237. }
  238. }
  239. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  240. extension Grpc_Health_V1_Health.ClientProtocol {
  241. /// Check gets the health of the specified service. If the requested service
  242. /// is unknown, the call will fail with status NOT_FOUND. If the caller does
  243. /// not specify a service name, the server should respond with its overall
  244. /// health status.
  245. ///
  246. /// Clients should set a deadline when calling Check, and can declare the
  247. /// server unhealthy if they do not receive a timely response.
  248. ///
  249. /// Check implementations should be idempotent and side effect free.
  250. package func check<Result>(
  251. _ message: Grpc_Health_V1_HealthCheckRequest,
  252. metadata: GRPCCore.Metadata = [:],
  253. options: GRPCCore.CallOptions = .defaults,
  254. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Health_V1_HealthCheckResponse>) async throws -> Result = {
  255. try $0.message
  256. }
  257. ) async throws -> Result where Result: Sendable {
  258. let request = GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>(
  259. message: message,
  260. metadata: metadata
  261. )
  262. return try await self.check(
  263. request: request,
  264. options: options,
  265. handleResponse
  266. )
  267. }
  268. /// Performs a watch for the serving status of the requested service.
  269. /// The server will immediately send back a message indicating the current
  270. /// serving status. It will then subsequently send a new message whenever
  271. /// the service's serving status changes.
  272. ///
  273. /// If the requested service is unknown when the call is received, the
  274. /// server will send a message setting the serving status to
  275. /// SERVICE_UNKNOWN but will *not* terminate the call. If at some
  276. /// future point, the serving status of the service becomes known, the
  277. /// server will send a new message with the service's serving status.
  278. ///
  279. /// If the call terminates with status UNIMPLEMENTED, then clients
  280. /// should assume this method is not supported and should not retry the
  281. /// call. If the call terminates with any other status (including OK),
  282. /// clients should retry the call with appropriate exponential backoff.
  283. package func watch<Result>(
  284. _ message: Grpc_Health_V1_HealthCheckRequest,
  285. metadata: GRPCCore.Metadata = [:],
  286. options: GRPCCore.CallOptions = .defaults,
  287. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Health_V1_HealthCheckResponse>) async throws -> Result
  288. ) async throws -> Result where Result: Sendable {
  289. let request = GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>(
  290. message: message,
  291. metadata: metadata
  292. )
  293. return try await self.watch(
  294. request: request,
  295. options: options,
  296. handleResponse
  297. )
  298. }
  299. }
  300. /// Health is gRPC's mechanism for checking whether a server is able to handle
  301. /// RPCs. Its semantics are documented in
  302. /// https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
  303. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  304. package struct Grpc_Health_V1_HealthClient: Grpc_Health_V1_Health.ClientProtocol {
  305. private let client: GRPCCore.GRPCClient
  306. package init(wrapping client: GRPCCore.GRPCClient) {
  307. self.client = client
  308. }
  309. /// Check gets the health of the specified service. If the requested service
  310. /// is unknown, the call will fail with status NOT_FOUND. If the caller does
  311. /// not specify a service name, the server should respond with its overall
  312. /// health status.
  313. ///
  314. /// Clients should set a deadline when calling Check, and can declare the
  315. /// server unhealthy if they do not receive a timely response.
  316. ///
  317. /// Check implementations should be idempotent and side effect free.
  318. package func check<R>(
  319. request: GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  320. serializer: some GRPCCore.MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
  321. deserializer: some GRPCCore.MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
  322. options: GRPCCore.CallOptions = .defaults,
  323. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Health_V1_HealthCheckResponse>) async throws -> R = {
  324. try $0.message
  325. }
  326. ) async throws -> R where R: Sendable {
  327. try await self.client.unary(
  328. request: request,
  329. descriptor: Grpc_Health_V1_Health.Method.Check.descriptor,
  330. serializer: serializer,
  331. deserializer: deserializer,
  332. options: options,
  333. handler: body
  334. )
  335. }
  336. /// Performs a watch for the serving status of the requested service.
  337. /// The server will immediately send back a message indicating the current
  338. /// serving status. It will then subsequently send a new message whenever
  339. /// the service's serving status changes.
  340. ///
  341. /// If the requested service is unknown when the call is received, the
  342. /// server will send a message setting the serving status to
  343. /// SERVICE_UNKNOWN but will *not* terminate the call. If at some
  344. /// future point, the serving status of the service becomes known, the
  345. /// server will send a new message with the service's serving status.
  346. ///
  347. /// If the call terminates with status UNIMPLEMENTED, then clients
  348. /// should assume this method is not supported and should not retry the
  349. /// call. If the call terminates with any other status (including OK),
  350. /// clients should retry the call with appropriate exponential backoff.
  351. package func watch<R>(
  352. request: GRPCCore.ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  353. serializer: some GRPCCore.MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
  354. deserializer: some GRPCCore.MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
  355. options: GRPCCore.CallOptions = .defaults,
  356. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
  357. ) async throws -> R where R: Sendable {
  358. try await self.client.serverStreaming(
  359. request: request,
  360. descriptor: Grpc_Health_V1_Health.Method.Watch.descriptor,
  361. serializer: serializer,
  362. deserializer: deserializer,
  363. options: options,
  364. handler: body
  365. )
  366. }
  367. }