Skip to content
Merged
18 changes: 16 additions & 2 deletions Package@swift-6.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ extension Target.Dependency {
static var grpcHTTP2Core: Self { .target(name: "GRPCHTTP2Core") }
static var grpcHTTP2TransportNIOPosix: Self { .target(name: "GRPCHTTP2TransportNIOPosix") }
static var grpcHTTP2TransportNIOTransportServices: Self { .target(name: "GRPCHTTP2TransportNIOTransportServices") }
static var grpcHealth: Self { .target(name: "GRPCHealth") }
}

// MARK: - Targets
Expand Down Expand Up @@ -510,6 +511,19 @@ extension Target {
)
}

static var grpcHealthTests: Target {
.testTarget(
name: "GRPCHealthTests",
dependencies: [
.grpcHealth,
.grpcProtobuf,
.grpcInProcessTransport
],
path: "Tests/Services/HealthTests",
swiftSettings: [._swiftLanguageMode(.v6), .enableUpcomingFeature("ExistentialAny")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the health module and health tests to use explicit imports like in Gus' PR #2003?

I'm happy for this to be done in a separate PR as well (actually it probably needs to be done separately because Gus needs to do the imports on the code-gen too).

)
}

static var interopTestModels: Target {
.target(
name: "GRPCInteroperabilityTestModels",
Expand Down Expand Up @@ -893,8 +907,7 @@ extension Target {
path: "Sources/Services/Health",
swiftSettings: [
._swiftLanguageMode(.v6),
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("InternalImportsByDefault")
.enableUpcomingFeature("ExistentialAny")
]
)
}
Expand Down Expand Up @@ -1046,6 +1059,7 @@ let package = Package(
.grpcInterceptorsTests,
.grpcHTTP2CoreTests,
.grpcHTTP2TransportTests,
.grpcHealthTests,
.grpcProtobufTests,
.grpcProtobufCodeGenTests,
.inProcessInteroperabilityTests,
Expand Down
4 changes: 2 additions & 2 deletions Protos/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ function generate_health_service {
local proto="$here/upstream/grpc/health/v1/health.proto"
local output="$root/Sources/Services/Health/Generated"

generate_message "$proto" "$(dirname "$proto")" "$output" "Visibility=Internal"
generate_grpc "$proto" "$(dirname "$proto")" "$output" "Visibility=Internal" "Client=false" "Server=true" "_V2=true"
generate_message "$proto" "$(dirname "$proto")" "$output" "Visibility=Package"
generate_grpc "$proto" "$(dirname "$proto")" "$output" "Visibility=Package" "Client=true" "Server=true" "_V2=true"
}

#------------------------------------------------------------------------------
Expand Down
187 changes: 169 additions & 18 deletions Sources/Services/Health/Generated/health.grpc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,44 @@
import GRPCCore
import GRPCProtobuf

internal enum Grpc_Health_V1_Health {
internal enum Method {
internal enum Check {
internal typealias Input = Grpc_Health_V1_HealthCheckRequest
internal typealias Output = Grpc_Health_V1_HealthCheckResponse
internal static let descriptor = MethodDescriptor(
package enum Grpc_Health_V1_Health {
package enum Method {
package enum Check {
package typealias Input = Grpc_Health_V1_HealthCheckRequest
package typealias Output = Grpc_Health_V1_HealthCheckResponse
package static let descriptor = MethodDescriptor(
service: "grpc.health.v1.Health",
method: "Check"
)
}
internal enum Watch {
internal typealias Input = Grpc_Health_V1_HealthCheckRequest
internal typealias Output = Grpc_Health_V1_HealthCheckResponse
internal static let descriptor = MethodDescriptor(
package enum Watch {
package typealias Input = Grpc_Health_V1_HealthCheckRequest
package typealias Output = Grpc_Health_V1_HealthCheckResponse
package static let descriptor = MethodDescriptor(
service: "grpc.health.v1.Health",
method: "Watch"
)
}
internal static let descriptors: [MethodDescriptor] = [
package static let descriptors: [MethodDescriptor] = [
Check.descriptor,
Watch.descriptor
]
}
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
internal typealias StreamingServiceProtocol = Grpc_Health_V1_HealthStreamingServiceProtocol
package typealias StreamingServiceProtocol = Grpc_Health_V1_HealthStreamingServiceProtocol
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
internal typealias ServiceProtocol = Grpc_Health_V1_HealthServiceProtocol
package typealias ServiceProtocol = Grpc_Health_V1_HealthServiceProtocol
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
package typealias ClientProtocol = Grpc_Health_V1_HealthClientProtocol
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
package typealias Client = Grpc_Health_V1_HealthClient
}

/// Health is gRPC's mechanism for checking whether a server is able to handle
/// RPCs. Its semantics are documented in
/// https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
internal protocol Grpc_Health_V1_HealthStreamingServiceProtocol: GRPCCore.RegistrableRPCService {
package protocol Grpc_Health_V1_HealthStreamingServiceProtocol: GRPCCore.RegistrableRPCService {
/// Check gets the health of the specified service. If the requested service
/// is unknown, the call will fail with status NOT_FOUND. If the caller does
/// not specify a service name, the server should respond with its overall
Expand Down Expand Up @@ -94,7 +98,7 @@ internal protocol Grpc_Health_V1_HealthStreamingServiceProtocol: GRPCCore.Regist
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension Grpc_Health_V1_Health.StreamingServiceProtocol {
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
internal func registerMethods(with router: inout GRPCCore.RPCRouter) {
package func registerMethods(with router: inout GRPCCore.RPCRouter) {
router.registerHandler(
forMethod: Grpc_Health_V1_Health.Method.Check.descriptor,
deserializer: ProtobufDeserializer<Grpc_Health_V1_HealthCheckRequest>(),
Expand All @@ -118,7 +122,7 @@ extension Grpc_Health_V1_Health.StreamingServiceProtocol {
/// RPCs. Its semantics are documented in
/// https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
internal protocol Grpc_Health_V1_HealthServiceProtocol: Grpc_Health_V1_Health.StreamingServiceProtocol {
package protocol Grpc_Health_V1_HealthServiceProtocol: Grpc_Health_V1_Health.StreamingServiceProtocol {
/// Check gets the health of the specified service. If the requested service
/// is unknown, the call will fail with status NOT_FOUND. If the caller does
/// not specify a service name, the server should respond with its overall
Expand Down Expand Up @@ -151,13 +155,160 @@ internal protocol Grpc_Health_V1_HealthServiceProtocol: Grpc_Health_V1_Health.St
/// Partial conformance to `Grpc_Health_V1_HealthStreamingServiceProtocol`.
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension Grpc_Health_V1_Health.ServiceProtocol {
internal func check(request: ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse> {
package func check(request: ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse> {
let response = try await self.check(request: ServerRequest.Single(stream: request))
return ServerResponse.Stream(single: response)
}

internal func watch(request: ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse> {
package func watch(request: ServerRequest.Stream<Grpc_Health_V1_HealthCheckRequest>) async throws -> ServerResponse.Stream<Grpc_Health_V1_HealthCheckResponse> {
let response = try await self.watch(request: ServerRequest.Single(stream: request))
return response
}
}

/// Health is gRPC's mechanism for checking whether a server is able to handle
/// RPCs. Its semantics are documented in
/// https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
package protocol Grpc_Health_V1_HealthClientProtocol: Sendable {
/// Check gets the health of the specified service. If the requested service
/// is unknown, the call will fail with status NOT_FOUND. If the caller does
/// not specify a service name, the server should respond with its overall
/// health status.
///
/// Clients should set a deadline when calling Check, and can declare the
/// server unhealthy if they do not receive a timely response.
///
/// Check implementations should be idempotent and side effect free.
func check<R>(
request: ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
serializer: some MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
deserializer: some MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
options: CallOptions,
_ body: @Sendable @escaping (ClientResponse.Single<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
) async throws -> R where R: Sendable

/// Performs a watch for the serving status of the requested service.
/// The server will immediately send back a message indicating the current
/// serving status. It will then subsequently send a new message whenever
/// the service's serving status changes.
///
/// If the requested service is unknown when the call is received, the
/// server will send a message setting the serving status to
/// SERVICE_UNKNOWN but will *not* terminate the call. If at some
/// future point, the serving status of the service becomes known, the
/// server will send a new message with the service's serving status.
///
/// If the call terminates with status UNIMPLEMENTED, then clients
/// should assume this method is not supported and should not retry the
/// call. If the call terminates with any other status (including OK),
/// clients should retry the call with appropriate exponential backoff.
func watch<R>(
request: ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
serializer: some MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
deserializer: some MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
options: CallOptions,
_ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
) async throws -> R where R: Sendable
}

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension Grpc_Health_V1_Health.ClientProtocol {
package func check<R>(
request: ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
options: CallOptions = .defaults,
_ body: @Sendable @escaping (ClientResponse.Single<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
) async throws -> R where R: Sendable {
try await self.check(
request: request,
serializer: ProtobufSerializer<Grpc_Health_V1_HealthCheckRequest>(),
deserializer: ProtobufDeserializer<Grpc_Health_V1_HealthCheckResponse>(),
options: options,
body
)
}

package func watch<R>(
request: ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
options: CallOptions = .defaults,
_ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
) async throws -> R where R: Sendable {
try await self.watch(
request: request,
serializer: ProtobufSerializer<Grpc_Health_V1_HealthCheckRequest>(),
deserializer: ProtobufDeserializer<Grpc_Health_V1_HealthCheckResponse>(),
options: options,
body
)
}
}

/// Health is gRPC's mechanism for checking whether a server is able to handle
/// RPCs. Its semantics are documented in
/// https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
package struct Grpc_Health_V1_HealthClient: Grpc_Health_V1_Health.ClientProtocol {
private let client: GRPCCore.GRPCClient

package init(client: GRPCCore.GRPCClient) {
self.client = client
}

/// Check gets the health of the specified service. If the requested service
/// is unknown, the call will fail with status NOT_FOUND. If the caller does
/// not specify a service name, the server should respond with its overall
/// health status.
///
/// Clients should set a deadline when calling Check, and can declare the
/// server unhealthy if they do not receive a timely response.
///
/// Check implementations should be idempotent and side effect free.
package func check<R>(
request: ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
serializer: some MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
deserializer: some MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
options: CallOptions = .defaults,
_ body: @Sendable @escaping (ClientResponse.Single<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
) async throws -> R where R: Sendable {
try await self.client.unary(
request: request,
descriptor: Grpc_Health_V1_Health.Method.Check.descriptor,
serializer: serializer,
deserializer: deserializer,
options: options,
handler: body
)
}

/// Performs a watch for the serving status of the requested service.
/// The server will immediately send back a message indicating the current
/// serving status. It will then subsequently send a new message whenever
/// the service's serving status changes.
///
/// If the requested service is unknown when the call is received, the
/// server will send a message setting the serving status to
/// SERVICE_UNKNOWN but will *not* terminate the call. If at some
/// future point, the serving status of the service becomes known, the
/// server will send a new message with the service's serving status.
///
/// If the call terminates with status UNIMPLEMENTED, then clients
/// should assume this method is not supported and should not retry the
/// call. If the call terminates with any other status (including OK),
/// clients should retry the call with appropriate exponential backoff.
package func watch<R>(
request: ClientRequest.Single<Grpc_Health_V1_HealthCheckRequest>,
serializer: some MessageSerializer<Grpc_Health_V1_HealthCheckRequest>,
deserializer: some MessageDeserializer<Grpc_Health_V1_HealthCheckResponse>,
options: CallOptions = .defaults,
_ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Health_V1_HealthCheckResponse>) async throws -> R
) async throws -> R where R: Sendable {
try await self.client.serverStreaming(
request: request,
descriptor: Grpc_Health_V1_Health.Method.Watch.descriptor,
serializer: serializer,
deserializer: deserializer,
options: options,
handler: body
)
}
}
Loading