health.grpc.swift 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. import GRPCCore
  25. import GRPCProtobuf
  26. package enum Grpc_Health_V1_Health {
  27. package static let descriptor = 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 = 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 = MethodDescriptor(
  41. service: Grpc_Health_V1_Health.descriptor.fullyQualifiedService,
  42. method: "Watch"
  43. )
  44. }
  45. package static let descriptors: [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 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: ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> 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: ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> 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: ProtobufDeserializer<Grpc_Health_V1_HealthCheckRequest>(),
  105. serializer: 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: ProtobufDeserializer<Grpc_Health_V1_HealthCheckRequest>(),
  113. serializer: 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: ServerRequest.Single<Grpc_Health_V1_HealthCheckRequest>) async throws -> 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: ServerRequest.Single<Grpc_Health_V1_HealthCheckRequest>) async throws -> 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: ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse> {
  156. let response = try await self.check(request: ServerRequest.Single(stream: request))
  157. return ServerResponse.Stream(single: response)
  158. }
  159. package func watch(request: ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse> {
  160. let response = try await self.watch(request: 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: ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  180. serializer: some MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
  181. deserializer: some MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
  182. options: CallOptions,
  183. _ body: @Sendable @escaping (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: ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  202. serializer: some MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
  203. deserializer: some MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
  204. options: CallOptions,
  205. _ body: @Sendable @escaping (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: ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  212. options: CallOptions = .defaults,
  213. _ body: @Sendable @escaping (ClientResponse.Single<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
  214. ) async throws -> R where R: Sendable {
  215. try await self.check(
  216. request: request,
  217. serializer: ProtobufSerializer<Grpc_Health_V1_HealthCheckRequest>(),
  218. deserializer: ProtobufDeserializer<Grpc_Health_V1_HealthCheckResponse>(),
  219. options: options,
  220. body
  221. )
  222. }
  223. package func watch<R>(
  224. request: ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  225. options: CallOptions = .defaults,
  226. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
  227. ) async throws -> R where R: Sendable {
  228. try await self.watch(
  229. request: request,
  230. serializer: ProtobufSerializer<Grpc_Health_V1_HealthCheckRequest>(),
  231. deserializer: ProtobufDeserializer<Grpc_Health_V1_HealthCheckResponse>(),
  232. options: options,
  233. body
  234. )
  235. }
  236. }
  237. /// Health is gRPC's mechanism for checking whether a server is able to handle
  238. /// RPCs. Its semantics are documented in
  239. /// https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
  240. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  241. package struct Grpc_Health_V1_HealthClient: Grpc_Health_V1_Health.ClientProtocol {
  242. private let client: GRPCCore.GRPCClient
  243. package init(wrapping client: GRPCCore.GRPCClient) {
  244. self.client = client
  245. }
  246. /// Check gets the health of the specified service. If the requested service
  247. /// is unknown, the call will fail with status NOT_FOUND. If the caller does
  248. /// not specify a service name, the server should respond with its overall
  249. /// health status.
  250. ///
  251. /// Clients should set a deadline when calling Check, and can declare the
  252. /// server unhealthy if they do not receive a timely response.
  253. ///
  254. /// Check implementations should be idempotent and side effect free.
  255. package func check<R>(
  256. request: ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  257. serializer: some MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
  258. deserializer: some MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
  259. options: CallOptions = .defaults,
  260. _ body: @Sendable @escaping (ClientResponse.Single<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
  261. ) async throws -> R where R: Sendable {
  262. try await self.client.unary(
  263. request: request,
  264. descriptor: Grpc_Health_V1_Health.Method.Check.descriptor,
  265. serializer: serializer,
  266. deserializer: deserializer,
  267. options: options,
  268. handler: body
  269. )
  270. }
  271. /// Performs a watch for the serving status of the requested service.
  272. /// The server will immediately send back a message indicating the current
  273. /// serving status. It will then subsequently send a new message whenever
  274. /// the service's serving status changes.
  275. ///
  276. /// If the requested service is unknown when the call is received, the
  277. /// server will send a message setting the serving status to
  278. /// SERVICE_UNKNOWN but will *not* terminate the call. If at some
  279. /// future point, the serving status of the service becomes known, the
  280. /// server will send a new message with the service's serving status.
  281. ///
  282. /// If the call terminates with status UNIMPLEMENTED, then clients
  283. /// should assume this method is not supported and should not retry the
  284. /// call. If the call terminates with any other status (including OK),
  285. /// clients should retry the call with appropriate exponential backoff.
  286. package func watch<R>(
  287. request: ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
  288. serializer: some MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
  289. deserializer: some MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
  290. options: CallOptions = .defaults,
  291. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
  292. ) async throws -> R where R: Sendable {
  293. try await self.client.serverStreaming(
  294. request: request,
  295. descriptor: Grpc_Health_V1_Health.Method.Watch.descriptor,
  296. serializer: serializer,
  297. deserializer: deserializer,
  298. options: options,
  299. handler: body
  300. )
  301. }
  302. }