health.grpc.swift 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. internal enum Grpc_Health_V1_Health {
  27. internal enum Method {
  28. internal enum Check {
  29. internal typealias Input = Grpc_Health_V1_HealthCheckRequest
  30. internal typealias Output = Grpc_Health_V1_HealthCheckResponse
  31. internal static let descriptor = MethodDescriptor(
  32. service: "grpc.health.v1.Health",
  33. method: "Check"
  34. )
  35. }
  36. internal enum Watch {
  37. internal typealias Input = Grpc_Health_V1_HealthCheckRequest
  38. internal typealias Output = Grpc_Health_V1_HealthCheckResponse
  39. internal static let descriptor = MethodDescriptor(
  40. service: "grpc.health.v1.Health",
  41. method: "Watch"
  42. )
  43. }
  44. internal static let descriptors: [MethodDescriptor] = [
  45. Check.descriptor,
  46. Watch.descriptor
  47. ]
  48. }
  49. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  50. internal typealias StreamingServiceProtocol = Grpc_Health_V1_HealthStreamingServiceProtocol
  51. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  52. internal typealias ServiceProtocol = Grpc_Health_V1_HealthServiceProtocol
  53. }
  54. /// Health is gRPC's mechanism for checking whether a server is able to handle
  55. /// RPCs. Its semantics are documented in
  56. /// https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
  57. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  58. internal protocol Grpc_Health_V1_HealthStreamingServiceProtocol: GRPCCore.RegistrableRPCService {
  59. /// Check gets the health of the specified service. If the requested service
  60. /// is unknown, the call will fail with status NOT_FOUND. If the caller does
  61. /// not specify a service name, the server should respond with its overall
  62. /// health status.
  63. ///
  64. /// Clients should set a deadline when calling Check, and can declare the
  65. /// server unhealthy if they do not receive a timely response.
  66. ///
  67. /// Check implementations should be idempotent and side effect free.
  68. func check(request: ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse>
  69. /// Performs a watch for the serving status of the requested service.
  70. /// The server will immediately send back a message indicating the current
  71. /// serving status. It will then subsequently send a new message whenever
  72. /// the service's serving status changes.
  73. ///
  74. /// If the requested service is unknown when the call is received, the
  75. /// server will send a message setting the serving status to
  76. /// SERVICE_UNKNOWN but will *not* terminate the call. If at some
  77. /// future point, the serving status of the service becomes known, the
  78. /// server will send a new message with the service's serving status.
  79. ///
  80. /// If the call terminates with status UNIMPLEMENTED, then clients
  81. /// should assume this method is not supported and should not retry the
  82. /// call. If the call terminates with any other status (including OK),
  83. /// clients should retry the call with appropriate exponential backoff.
  84. func watch(request: ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse>
  85. }
  86. /// Conformance to `GRPCCore.RegistrableRPCService`.
  87. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  88. extension Grpc_Health_V1_Health.StreamingServiceProtocol {
  89. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  90. internal func registerMethods(with router: inout GRPCCore.RPCRouter) {
  91. router.registerHandler(
  92. forMethod: Grpc_Health_V1_Health.Method.Check.descriptor,
  93. deserializer: ProtobufDeserializer<Grpc_Health_V1_HealthCheckRequest>(),
  94. serializer: ProtobufSerializer<Grpc_Health_V1_HealthCheckResponse>(),
  95. handler: { request in
  96. try await self.check(request: request)
  97. }
  98. )
  99. router.registerHandler(
  100. forMethod: Grpc_Health_V1_Health.Method.Watch.descriptor,
  101. deserializer: ProtobufDeserializer<Grpc_Health_V1_HealthCheckRequest>(),
  102. serializer: ProtobufSerializer<Grpc_Health_V1_HealthCheckResponse>(),
  103. handler: { request in
  104. try await self.watch(request: request)
  105. }
  106. )
  107. }
  108. }
  109. /// Health is gRPC's mechanism for checking whether a server is able to handle
  110. /// RPCs. Its semantics are documented in
  111. /// https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
  112. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  113. internal protocol Grpc_Health_V1_HealthServiceProtocol: Grpc_Health_V1_Health.StreamingServiceProtocol {
  114. /// Check gets the health of the specified service. If the requested service
  115. /// is unknown, the call will fail with status NOT_FOUND. If the caller does
  116. /// not specify a service name, the server should respond with its overall
  117. /// health status.
  118. ///
  119. /// Clients should set a deadline when calling Check, and can declare the
  120. /// server unhealthy if they do not receive a timely response.
  121. ///
  122. /// Check implementations should be idempotent and side effect free.
  123. func check(request: ServerRequest.Single<Grpc_Health_V1_HealthCheckRequest>) async throws -> ServerResponse.Single<Grpc_Health_V1_HealthCheckResponse>
  124. /// Performs a watch for the serving status of the requested service.
  125. /// The server will immediately send back a message indicating the current
  126. /// serving status. It will then subsequently send a new message whenever
  127. /// the service's serving status changes.
  128. ///
  129. /// If the requested service is unknown when the call is received, the
  130. /// server will send a message setting the serving status to
  131. /// SERVICE_UNKNOWN but will *not* terminate the call. If at some
  132. /// future point, the serving status of the service becomes known, the
  133. /// server will send a new message with the service's serving status.
  134. ///
  135. /// If the call terminates with status UNIMPLEMENTED, then clients
  136. /// should assume this method is not supported and should not retry the
  137. /// call. If the call terminates with any other status (including OK),
  138. /// clients should retry the call with appropriate exponential backoff.
  139. func watch(request: ServerRequest.Single<Grpc_Health_V1_HealthCheckRequest>) async throws -> ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse>
  140. }
  141. /// Partial conformance to `Grpc_Health_V1_HealthStreamingServiceProtocol`.
  142. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  143. extension Grpc_Health_V1_Health.ServiceProtocol {
  144. internal func check(request: ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse> {
  145. let response = try await self.check(request: ServerRequest.Single(stream: request))
  146. return ServerResponse.Stream(single: response)
  147. }
  148. internal func watch(request: ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse> {
  149. let response = try await self.watch(request: ServerRequest.Single(stream: request))
  150. return response
  151. }
  152. }