health.grpc.swift 16 KB

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