From 5fefa12f8132126651e0d3319c0526bffe1bee32 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Fri, 9 Aug 2024 17:27:45 +0100 Subject: [PATCH 1/2] Add check that generated code is up-to-date Motivation: It's easy for checked in generated code to not be up-to-date. Modifications: - Add a script to check it's up-to-date and run it in CI - That CI job now requires the Swift 6 toolchain, so we now rely on swift-format from the toolchain - Also fixes casing issues in the genreate script Result: More guarantess that checked in code is up-to-date --- .github/workflows/ci.yaml | 19 ++++------ Protos/generate.sh | 2 +- scripts/check-generated-code.sh | 32 ++++++++++++++++ scripts/format.sh | 65 ++++++++------------------------- scripts/sanity.sh | 11 ++++-- 5 files changed, 65 insertions(+), 64 deletions(-) create mode 100755 scripts/check-generated-code.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 26d4e0447..1b348667d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,20 +9,17 @@ jobs: name: License Header and Formatting Checks runs-on: ubuntu-latest container: - image: swift + image: swiftlang/swift:nightly-6.0-jammy steps: - - uses: actions/checkout@v4 - - uses: actions/cache/restore@v4 - with: - path: scripts/.swift-format-source - key: ${{ runner.os }}-swift-format - - name: "Formatting and License Headers check" + - name: "Checkout repository" + uses: actions/checkout@v4 + - name: Mark the workspace as safe + run: git config --global --add safe.directory ${GITHUB_WORKSPACE} + - name: "Install protoc" + run: apt update && apt install -y protobuf-compiler + - name: "Formatting, License Headers, and Generated Code check" run: | ./scripts/sanity.sh - - uses: actions/cache/save@v4 - with: - path: scripts/.swift-format-source - key: ${{ runner.os }}-swift-format unit-tests: strategy: fail-fast: false diff --git a/Protos/generate.sh b/Protos/generate.sh index 3e5c05631..17c803049 100755 --- a/Protos/generate.sh +++ b/Protos/generate.sh @@ -119,7 +119,7 @@ function generate_reflection_service { mv "$output_v1/reflection.grpc.swift" "$output_v1/reflection-v1.grpc.swift" local proto_v1alpha="$here/upstream/grpc/reflection/v1alpha/reflection.proto" - local output_v1alpha="$root/Sources/GRPCReflectionService/v1alpha" + local output_v1alpha="$root/Sources/GRPCReflectionService/v1Alpha" # Messages were accidentally leaked into public API, they shouldn't be but we # can't undo that change until the next major version. diff --git a/scripts/check-generated-code.sh b/scripts/check-generated-code.sh new file mode 100755 index 000000000..3444d9d88 --- /dev/null +++ b/scripts/check-generated-code.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Copyright 2024, gRPC Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -euo pipefail + +log() { printf -- "** %s\n" "$*" >&2; } +error() { printf -- "** ERROR: %s\n" "$*" >&2; } +fatal() { error "$@"; exit 1; } + +here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# Re-generate everything. +log "Regenerating protos..." +"$here"/../Protos/generate.sh + +# Check for changes. +GIT_PAGER='' git diff --exit-code '*.swift' + +log "Generated code is up-to-date" diff --git a/scripts/format.sh b/scripts/format.sh index 1e3d7801b..f9ded9164 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -52,53 +52,20 @@ while getopts ":flh" opt; do esac done -THIS_SCRIPT=$0 -HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -REPO="$HERE/.." -SWIFTFORMAT_DIR="$HERE/.swift-format-source" -SWIFTFORMAT_VERSION=510.0.0 - -# Clone SwiftFormat if we don't already have it. -if [ ! -d "$SWIFTFORMAT_DIR" ]; then - echo "- Cloning swift-format @ $SWIFTFORMAT_VERSION" - git clone \ - --depth 1 \ - --branch "$SWIFTFORMAT_VERSION" \ - https://github.com/apple/swift-format.git \ - "$SWIFTFORMAT_DIR" -fi - -cd "$SWIFTFORMAT_DIR" - -# Figure out the path for the binary. -SWIFTFORMAT_BIN="$(swift build --show-bin-path -c release)/swift-format-$SWIFTFORMAT_VERSION" - -# Build it if we don't already have it. -if [ ! -f "$SWIFTFORMAT_BIN" ]; then - # We're not on the right tag, fetch and checkout the right one. - echo "- Fetching swift-format @ $SWIFTFORMAT_VERSION" - git fetch --depth 1 origin "refs/tags/$SWIFTFORMAT_VERSION:refs/tags/$SWIFTFORMAT_VERSION" - git checkout "$SWIFTFORMAT_VERSION" - - # Now build and name the bin appropriately. - echo "- Building swift-format @ $SWIFTFORMAT_VERSION" - swift build -c release --product swift-format - mv "$(swift build --show-bin-path -c release)/swift-format" "$SWIFTFORMAT_BIN" - - echo "- OK" -fi +here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +repo="$here/.." if "$lint"; then - "${SWIFTFORMAT_BIN}" lint \ + swift format lint \ --parallel --recursive --strict \ - "${REPO}/Sources" \ - "${REPO}/Tests" \ - "${REPO}/Plugins" \ - "${REPO}/Performance/Benchmarks/Benchmarks/GRPCSwiftBenchmark" \ + "${repo}/Sources" \ + "${repo}/Tests" \ + "${repo}/Plugins" \ + "${repo}/Performance/Benchmarks/Benchmarks/GRPCSwiftBenchmark" \ && SWIFT_FORMAT_RC=$? || SWIFT_FORMAT_RC=$? if [[ "${SWIFT_FORMAT_RC}" -ne 0 ]]; then - fatal "Running swift-format produced errors. + fatal "Running swift format produced errors. To fix, run the following command: @@ -107,21 +74,21 @@ if "$lint"; then exit "${SWIFT_FORMAT_RC}" fi - log "Ran swift-format lint with no errors." + log "Ran swift format lint with no errors." elif "$format"; then - "${SWIFTFORMAT_BIN}" format \ + swift format \ --parallel --recursive --in-place \ - "${REPO}/Sources" \ - "${REPO}/Tests" \ - "${REPO}/Plugins" \ - "${REPO}/Performance/Benchmarks/Benchmarks/GRPCSwiftBenchmark" \ + "${repo}/Sources" \ + "${repo}/Tests" \ + "${repo}/Plugins" \ + "${repo}/Performance/Benchmarks/Benchmarks/GRPCSwiftBenchmark" \ && SWIFT_FORMAT_RC=$? || SWIFT_FORMAT_RC=$? if [[ "${SWIFT_FORMAT_RC}" -ne 0 ]]; then - fatal "Running swift-format produced errors." "${SWIFT_FORMAT_RC}" + fatal "Running swift format produced errors." "${SWIFT_FORMAT_RC}" fi - log "Ran swift-format with no errors." + log "Ran swift format with no errors." else fatal "No actions taken." fi diff --git a/scripts/sanity.sh b/scripts/sanity.sh index a290eb9f7..de039b514 100755 --- a/scripts/sanity.sh +++ b/scripts/sanity.sh @@ -16,7 +16,7 @@ set -eu -HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" function run_logged() { local message=$1 @@ -38,14 +38,19 @@ function run_logged() { } function check_license_headers() { - run_logged "Checking license headers" "$HERE/license-check.sh" + run_logged "Checking license headers" "$here/license-check.sh" } function check_formatting() { - run_logged "Checking formatting" "$HERE/format.sh -l" + run_logged "Checking formatting" "$here/format.sh -l" +} + +function check_generated_code_is_up_to_date() { + run_logged "Checking generated code is up-to-date" "$here/check-generated-code.sh" } errors=0 check_license_headers check_formatting +check_generated_code_is_up_to_date exit $errors From fefca2463faac8650414eb87597ef6b1300a6fe5 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Fri, 9 Aug 2024 18:41:54 +0100 Subject: [PATCH 2/2] Regenerate --- .../v2/Echo/Generated/echo.grpc.swift | 38 +++---- .../Generated/empty_service.grpc.swift | 2 +- .../Generated/test.grpc.swift | 104 +++++++++--------- .../Health/Generated/health.grpc.swift | 16 +-- .../grpc_testing_benchmark_service.grpc.swift | 48 ++++---- .../Generated/grpc_testing_control.pb.swift | 8 +- .../grpc_testing_worker_service.grpc.swift | 14 +-- .../Generated/control.grpc.swift | 38 +++---- 8 files changed, 134 insertions(+), 134 deletions(-) diff --git a/Sources/Examples/v2/Echo/Generated/echo.grpc.swift b/Sources/Examples/v2/Echo/Generated/echo.grpc.swift index d21a7a327..797ab5ca5 100644 --- a/Sources/Examples/v2/Echo/Generated/echo.grpc.swift +++ b/Sources/Examples/v2/Echo/Generated/echo.grpc.swift @@ -87,13 +87,13 @@ extension ServiceDescriptor { internal protocol Echo_EchoStreamingServiceProtocol: GRPCCore.RegistrableRPCService { /// Immediately returns an echo of a request. func get(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// Splits a request into words and returns each word in a stream of messages. func expand(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// Collects a stream of messages and returns them concatenated when the caller closes. func collect(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// Streams back messages as they are received in an input stream. func update(request: ServerRequest.Stream) async throws -> ServerResponse.Stream } @@ -142,13 +142,13 @@ extension Echo_Echo.StreamingServiceProtocol { internal protocol Echo_EchoServiceProtocol: Echo_Echo.StreamingServiceProtocol { /// Immediately returns an echo of a request. func get(request: ServerRequest.Single) async throws -> ServerResponse.Single - + /// Splits a request into words and returns each word in a stream of messages. func expand(request: ServerRequest.Single) async throws -> ServerResponse.Stream - + /// Collects a stream of messages and returns them concatenated when the caller closes. func collect(request: ServerRequest.Stream) async throws -> ServerResponse.Single - + /// Streams back messages as they are received in an input stream. func update(request: ServerRequest.Stream) async throws -> ServerResponse.Stream } @@ -160,12 +160,12 @@ extension Echo_Echo.ServiceProtocol { let response = try await self.get(request: ServerRequest.Single(stream: request)) return ServerResponse.Stream(single: response) } - + internal func expand(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.expand(request: ServerRequest.Single(stream: request)) return response } - + internal func collect(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.collect(request: request) return ServerResponse.Stream(single: response) @@ -182,7 +182,7 @@ internal protocol Echo_EchoClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable - + /// Splits a request into words and returns each word in a stream of messages. func expand( request: ClientRequest.Single, @@ -191,7 +191,7 @@ internal protocol Echo_EchoClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable - + /// Collects a stream of messages and returns them concatenated when the caller closes. func collect( request: ClientRequest.Stream, @@ -200,7 +200,7 @@ internal protocol Echo_EchoClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable - + /// Streams back messages as they are received in an input stream. func update( request: ClientRequest.Stream, @@ -226,7 +226,7 @@ extension Echo_Echo.ClientProtocol { body ) } - + internal func expand( request: ClientRequest.Single, options: CallOptions = .defaults, @@ -240,7 +240,7 @@ extension Echo_Echo.ClientProtocol { body ) } - + internal func collect( request: ClientRequest.Stream, options: CallOptions = .defaults, @@ -254,7 +254,7 @@ extension Echo_Echo.ClientProtocol { body ) } - + internal func update( request: ClientRequest.Stream, options: CallOptions = .defaults, @@ -273,11 +273,11 @@ extension Echo_Echo.ClientProtocol { @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) internal struct Echo_EchoClient: Echo_Echo.ClientProtocol { private let client: GRPCCore.GRPCClient - + internal init(wrapping client: GRPCCore.GRPCClient) { self.client = client } - + /// Immediately returns an echo of a request. internal func get( request: ClientRequest.Single, @@ -295,7 +295,7 @@ internal struct Echo_EchoClient: Echo_Echo.ClientProtocol { handler: body ) } - + /// Splits a request into words and returns each word in a stream of messages. internal func expand( request: ClientRequest.Single, @@ -313,7 +313,7 @@ internal struct Echo_EchoClient: Echo_Echo.ClientProtocol { handler: body ) } - + /// Collects a stream of messages and returns them concatenated when the caller closes. internal func collect( request: ClientRequest.Stream, @@ -331,7 +331,7 @@ internal struct Echo_EchoClient: Echo_Echo.ClientProtocol { handler: body ) } - + /// Streams back messages as they are received in an input stream. internal func update( request: ClientRequest.Stream, diff --git a/Sources/InteroperabilityTests/Generated/empty_service.grpc.swift b/Sources/InteroperabilityTests/Generated/empty_service.grpc.swift index c277d42c3..a28e39ff5 100644 --- a/Sources/InteroperabilityTests/Generated/empty_service.grpc.swift +++ b/Sources/InteroperabilityTests/Generated/empty_service.grpc.swift @@ -82,7 +82,7 @@ extension Grpc_Testing_EmptyService.ClientProtocol { @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) public struct Grpc_Testing_EmptyServiceClient: Grpc_Testing_EmptyService.ClientProtocol { private let client: GRPCCore.GRPCClient - + public init(wrapping client: GRPCCore.GRPCClient) { self.client = client } diff --git a/Sources/InteroperabilityTests/Generated/test.grpc.swift b/Sources/InteroperabilityTests/Generated/test.grpc.swift index 2ef5fc243..b42989ccc 100644 --- a/Sources/InteroperabilityTests/Generated/test.grpc.swift +++ b/Sources/InteroperabilityTests/Generated/test.grpc.swift @@ -201,34 +201,34 @@ extension ServiceDescriptor { public protocol Grpc_Testing_TestServiceStreamingServiceProtocol: GRPCCore.RegistrableRPCService { /// One empty request followed by one empty response. func emptyCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// One request followed by one response. func unaryCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// One request followed by one response. Response has cache control /// headers set such that a caching HTTP proxy (such as GFE) can /// satisfy subsequent requests. func cacheableUnaryCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// One request followed by a sequence of responses (streamed download). /// The server returns the payload with client desired type and sizes. func streamingOutputCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// A sequence of requests followed by one response (streamed upload). /// The server returns the aggregated size of client payload as the result. func streamingInputCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// A sequence of requests with each request served by the server immediately. /// As one request could lead to multiple responses, this interface /// demonstrates the idea of full duplexing. func fullDuplexCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// A sequence of requests followed by a sequence of responses. /// The server buffers all the client requests and then serves them in order. A /// stream of responses are returned to the client when the server starts with /// first request. func halfDuplexCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// The test server will not implement this method. It will be used /// to test the behavior when clients call unimplemented methods. func unimplementedCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream @@ -312,34 +312,34 @@ extension Grpc_Testing_TestService.StreamingServiceProtocol { public protocol Grpc_Testing_TestServiceServiceProtocol: Grpc_Testing_TestService.StreamingServiceProtocol { /// One empty request followed by one empty response. func emptyCall(request: ServerRequest.Single) async throws -> ServerResponse.Single - + /// One request followed by one response. func unaryCall(request: ServerRequest.Single) async throws -> ServerResponse.Single - + /// One request followed by one response. Response has cache control /// headers set such that a caching HTTP proxy (such as GFE) can /// satisfy subsequent requests. func cacheableUnaryCall(request: ServerRequest.Single) async throws -> ServerResponse.Single - + /// One request followed by a sequence of responses (streamed download). /// The server returns the payload with client desired type and sizes. func streamingOutputCall(request: ServerRequest.Single) async throws -> ServerResponse.Stream - + /// A sequence of requests followed by one response (streamed upload). /// The server returns the aggregated size of client payload as the result. func streamingInputCall(request: ServerRequest.Stream) async throws -> ServerResponse.Single - + /// A sequence of requests with each request served by the server immediately. /// As one request could lead to multiple responses, this interface /// demonstrates the idea of full duplexing. func fullDuplexCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// A sequence of requests followed by a sequence of responses. /// The server buffers all the client requests and then serves them in order. A /// stream of responses are returned to the client when the server starts with /// first request. func halfDuplexCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// The test server will not implement this method. It will be used /// to test the behavior when clients call unimplemented methods. func unimplementedCall(request: ServerRequest.Single) async throws -> ServerResponse.Single @@ -352,27 +352,27 @@ extension Grpc_Testing_TestService.ServiceProtocol { let response = try await self.emptyCall(request: ServerRequest.Single(stream: request)) return ServerResponse.Stream(single: response) } - + public func unaryCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.unaryCall(request: ServerRequest.Single(stream: request)) return ServerResponse.Stream(single: response) } - + public func cacheableUnaryCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.cacheableUnaryCall(request: ServerRequest.Single(stream: request)) return ServerResponse.Stream(single: response) } - + public func streamingOutputCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.streamingOutputCall(request: ServerRequest.Single(stream: request)) return response } - + public func streamingInputCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.streamingInputCall(request: request) return ServerResponse.Stream(single: response) } - + public func unimplementedCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.unimplementedCall(request: ServerRequest.Single(stream: request)) return ServerResponse.Stream(single: response) @@ -424,7 +424,7 @@ extension Grpc_Testing_UnimplementedService.ServiceProtocol { @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) public protocol Grpc_Testing_ReconnectServiceStreamingServiceProtocol: GRPCCore.RegistrableRPCService { func start(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + func stop(request: ServerRequest.Stream) async throws -> ServerResponse.Stream } @@ -456,7 +456,7 @@ extension Grpc_Testing_ReconnectService.StreamingServiceProtocol { @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) public protocol Grpc_Testing_ReconnectServiceServiceProtocol: Grpc_Testing_ReconnectService.StreamingServiceProtocol { func start(request: ServerRequest.Single) async throws -> ServerResponse.Single - + func stop(request: ServerRequest.Single) async throws -> ServerResponse.Single } @@ -467,7 +467,7 @@ extension Grpc_Testing_ReconnectService.ServiceProtocol { let response = try await self.start(request: ServerRequest.Single(stream: request)) return ServerResponse.Stream(single: response) } - + public func stop(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.stop(request: ServerRequest.Single(stream: request)) return ServerResponse.Stream(single: response) @@ -486,7 +486,7 @@ public protocol Grpc_Testing_TestServiceClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable - + /// One request followed by one response. func unaryCall( request: ClientRequest.Single, @@ -495,7 +495,7 @@ public protocol Grpc_Testing_TestServiceClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable - + /// One request followed by one response. Response has cache control /// headers set such that a caching HTTP proxy (such as GFE) can /// satisfy subsequent requests. @@ -506,7 +506,7 @@ public protocol Grpc_Testing_TestServiceClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable - + /// One request followed by a sequence of responses (streamed download). /// The server returns the payload with client desired type and sizes. func streamingOutputCall( @@ -516,7 +516,7 @@ public protocol Grpc_Testing_TestServiceClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable - + /// A sequence of requests followed by one response (streamed upload). /// The server returns the aggregated size of client payload as the result. func streamingInputCall( @@ -526,7 +526,7 @@ public protocol Grpc_Testing_TestServiceClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable - + /// A sequence of requests with each request served by the server immediately. /// As one request could lead to multiple responses, this interface /// demonstrates the idea of full duplexing. @@ -537,7 +537,7 @@ public protocol Grpc_Testing_TestServiceClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable - + /// A sequence of requests followed by a sequence of responses. /// The server buffers all the client requests and then serves them in order. A /// stream of responses are returned to the client when the server starts with @@ -549,7 +549,7 @@ public protocol Grpc_Testing_TestServiceClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable - + /// The test server will not implement this method. It will be used /// to test the behavior when clients call unimplemented methods. func unimplementedCall( @@ -576,7 +576,7 @@ extension Grpc_Testing_TestService.ClientProtocol { body ) } - + public func unaryCall( request: ClientRequest.Single, options: CallOptions = .defaults, @@ -590,7 +590,7 @@ extension Grpc_Testing_TestService.ClientProtocol { body ) } - + public func cacheableUnaryCall( request: ClientRequest.Single, options: CallOptions = .defaults, @@ -604,7 +604,7 @@ extension Grpc_Testing_TestService.ClientProtocol { body ) } - + public func streamingOutputCall( request: ClientRequest.Single, options: CallOptions = .defaults, @@ -618,7 +618,7 @@ extension Grpc_Testing_TestService.ClientProtocol { body ) } - + public func streamingInputCall( request: ClientRequest.Stream, options: CallOptions = .defaults, @@ -632,7 +632,7 @@ extension Grpc_Testing_TestService.ClientProtocol { body ) } - + public func fullDuplexCall( request: ClientRequest.Stream, options: CallOptions = .defaults, @@ -646,7 +646,7 @@ extension Grpc_Testing_TestService.ClientProtocol { body ) } - + public func halfDuplexCall( request: ClientRequest.Stream, options: CallOptions = .defaults, @@ -660,7 +660,7 @@ extension Grpc_Testing_TestService.ClientProtocol { body ) } - + public func unimplementedCall( request: ClientRequest.Single, options: CallOptions = .defaults, @@ -681,11 +681,11 @@ extension Grpc_Testing_TestService.ClientProtocol { @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) public struct Grpc_Testing_TestServiceClient: Grpc_Testing_TestService.ClientProtocol { private let client: GRPCCore.GRPCClient - + public init(wrapping client: GRPCCore.GRPCClient) { self.client = client } - + /// One empty request followed by one empty response. public func emptyCall( request: ClientRequest.Single, @@ -703,7 +703,7 @@ public struct Grpc_Testing_TestServiceClient: Grpc_Testing_TestService.ClientPro handler: body ) } - + /// One request followed by one response. public func unaryCall( request: ClientRequest.Single, @@ -721,7 +721,7 @@ public struct Grpc_Testing_TestServiceClient: Grpc_Testing_TestService.ClientPro handler: body ) } - + /// One request followed by one response. Response has cache control /// headers set such that a caching HTTP proxy (such as GFE) can /// satisfy subsequent requests. @@ -741,7 +741,7 @@ public struct Grpc_Testing_TestServiceClient: Grpc_Testing_TestService.ClientPro handler: body ) } - + /// One request followed by a sequence of responses (streamed download). /// The server returns the payload with client desired type and sizes. public func streamingOutputCall( @@ -760,7 +760,7 @@ public struct Grpc_Testing_TestServiceClient: Grpc_Testing_TestService.ClientPro handler: body ) } - + /// A sequence of requests followed by one response (streamed upload). /// The server returns the aggregated size of client payload as the result. public func streamingInputCall( @@ -779,7 +779,7 @@ public struct Grpc_Testing_TestServiceClient: Grpc_Testing_TestService.ClientPro handler: body ) } - + /// A sequence of requests with each request served by the server immediately. /// As one request could lead to multiple responses, this interface /// demonstrates the idea of full duplexing. @@ -799,7 +799,7 @@ public struct Grpc_Testing_TestServiceClient: Grpc_Testing_TestService.ClientPro handler: body ) } - + /// A sequence of requests followed by a sequence of responses. /// The server buffers all the client requests and then serves them in order. A /// stream of responses are returned to the client when the server starts with @@ -820,7 +820,7 @@ public struct Grpc_Testing_TestServiceClient: Grpc_Testing_TestService.ClientPro handler: body ) } - + /// The test server will not implement this method. It will be used /// to test the behavior when clients call unimplemented methods. public func unimplementedCall( @@ -877,11 +877,11 @@ extension Grpc_Testing_UnimplementedService.ClientProtocol { @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) public struct Grpc_Testing_UnimplementedServiceClient: Grpc_Testing_UnimplementedService.ClientProtocol { private let client: GRPCCore.GRPCClient - + public init(wrapping client: GRPCCore.GRPCClient) { self.client = client } - + /// A call that no server should implement public func unimplementedCall( request: ClientRequest.Single, @@ -911,7 +911,7 @@ public protocol Grpc_Testing_ReconnectServiceClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable - + func stop( request: ClientRequest.Single, serializer: some MessageSerializer, @@ -936,7 +936,7 @@ extension Grpc_Testing_ReconnectService.ClientProtocol { body ) } - + public func stop( request: ClientRequest.Single, options: CallOptions = .defaults, @@ -956,11 +956,11 @@ extension Grpc_Testing_ReconnectService.ClientProtocol { @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) public struct Grpc_Testing_ReconnectServiceClient: Grpc_Testing_ReconnectService.ClientProtocol { private let client: GRPCCore.GRPCClient - + public init(wrapping client: GRPCCore.GRPCClient) { self.client = client } - + public func start( request: ClientRequest.Single, serializer: some MessageSerializer, @@ -977,7 +977,7 @@ public struct Grpc_Testing_ReconnectServiceClient: Grpc_Testing_ReconnectService handler: body ) } - + public func stop( request: ClientRequest.Single, serializer: some MessageSerializer, diff --git a/Sources/Services/Health/Generated/health.grpc.swift b/Sources/Services/Health/Generated/health.grpc.swift index 6316b5b55..504dd871e 100644 --- a/Sources/Services/Health/Generated/health.grpc.swift +++ b/Sources/Services/Health/Generated/health.grpc.swift @@ -83,7 +83,7 @@ package protocol Grpc_Health_V1_HealthStreamingServiceProtocol: GRPCCore.Registr /// /// Check implementations should be idempotent and side effect free. func check(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// 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 @@ -141,7 +141,7 @@ package protocol Grpc_Health_V1_HealthServiceProtocol: Grpc_Health_V1_Health.Str /// /// Check implementations should be idempotent and side effect free. func check(request: ServerRequest.Single) async throws -> ServerResponse.Single - + /// 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 @@ -167,7 +167,7 @@ extension Grpc_Health_V1_Health.ServiceProtocol { let response = try await self.check(request: ServerRequest.Single(stream: request)) return ServerResponse.Stream(single: response) } - + package func watch(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.watch(request: ServerRequest.Single(stream: request)) return response @@ -195,7 +195,7 @@ package protocol Grpc_Health_V1_HealthClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Single) 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 @@ -235,7 +235,7 @@ extension Grpc_Health_V1_Health.ClientProtocol { body ) } - + package func watch( request: ClientRequest.Single, options: CallOptions = .defaults, @@ -257,11 +257,11 @@ extension Grpc_Health_V1_Health.ClientProtocol { @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(wrapping 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 @@ -287,7 +287,7 @@ package struct Grpc_Health_V1_HealthClient: Grpc_Health_V1_Health.ClientProtocol 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 diff --git a/Sources/performance-worker/Generated/grpc_testing_benchmark_service.grpc.swift b/Sources/performance-worker/Generated/grpc_testing_benchmark_service.grpc.swift index 73ddaeabf..7e3c95084 100644 --- a/Sources/performance-worker/Generated/grpc_testing_benchmark_service.grpc.swift +++ b/Sources/performance-worker/Generated/grpc_testing_benchmark_service.grpc.swift @@ -100,20 +100,20 @@ internal protocol Grpc_Testing_BenchmarkServiceStreamingServiceProtocol: GRPCCor /// One request followed by one response. /// The server returns the client payload as-is. func unaryCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// Repeated sequence of one request followed by one response. /// Should be called streaming ping-pong /// The server returns the client payload as-is on each response func streamingCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// Single-sided unbounded streaming from client to server /// The server returns the client payload as-is once the client does WritesDone func streamingFromClient(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// Single-sided unbounded streaming from server to client /// The server repeatedly returns the client payload as-is func streamingFromServer(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// Two-sided unbounded streaming between server to client /// Both sides send the content of their own choice to the other func streamingBothWays(request: ServerRequest.Stream) async throws -> ServerResponse.Stream @@ -172,20 +172,20 @@ internal protocol Grpc_Testing_BenchmarkServiceServiceProtocol: Grpc_Testing_Ben /// One request followed by one response. /// The server returns the client payload as-is. func unaryCall(request: ServerRequest.Single) async throws -> ServerResponse.Single - + /// Repeated sequence of one request followed by one response. /// Should be called streaming ping-pong /// The server returns the client payload as-is on each response func streamingCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// Single-sided unbounded streaming from client to server /// The server returns the client payload as-is once the client does WritesDone func streamingFromClient(request: ServerRequest.Stream) async throws -> ServerResponse.Single - + /// Single-sided unbounded streaming from server to client /// The server repeatedly returns the client payload as-is func streamingFromServer(request: ServerRequest.Single) async throws -> ServerResponse.Stream - + /// Two-sided unbounded streaming between server to client /// Both sides send the content of their own choice to the other func streamingBothWays(request: ServerRequest.Stream) async throws -> ServerResponse.Stream @@ -198,12 +198,12 @@ extension Grpc_Testing_BenchmarkService.ServiceProtocol { let response = try await self.unaryCall(request: ServerRequest.Single(stream: request)) return ServerResponse.Stream(single: response) } - + internal func streamingFromClient(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.streamingFromClient(request: request) return ServerResponse.Stream(single: response) } - + internal func streamingFromServer(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.streamingFromServer(request: ServerRequest.Single(stream: request)) return response @@ -221,7 +221,7 @@ internal protocol Grpc_Testing_BenchmarkServiceClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable - + /// Repeated sequence of one request followed by one response. /// Should be called streaming ping-pong /// The server returns the client payload as-is on each response @@ -232,7 +232,7 @@ internal protocol Grpc_Testing_BenchmarkServiceClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable - + /// Single-sided unbounded streaming from client to server /// The server returns the client payload as-is once the client does WritesDone func streamingFromClient( @@ -242,7 +242,7 @@ internal protocol Grpc_Testing_BenchmarkServiceClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable - + /// Single-sided unbounded streaming from server to client /// The server repeatedly returns the client payload as-is func streamingFromServer( @@ -252,7 +252,7 @@ internal protocol Grpc_Testing_BenchmarkServiceClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable - + /// Two-sided unbounded streaming between server to client /// Both sides send the content of their own choice to the other func streamingBothWays( @@ -279,7 +279,7 @@ extension Grpc_Testing_BenchmarkService.ClientProtocol { body ) } - + internal func streamingCall( request: ClientRequest.Stream, options: CallOptions = .defaults, @@ -293,7 +293,7 @@ extension Grpc_Testing_BenchmarkService.ClientProtocol { body ) } - + internal func streamingFromClient( request: ClientRequest.Stream, options: CallOptions = .defaults, @@ -307,7 +307,7 @@ extension Grpc_Testing_BenchmarkService.ClientProtocol { body ) } - + internal func streamingFromServer( request: ClientRequest.Single, options: CallOptions = .defaults, @@ -321,7 +321,7 @@ extension Grpc_Testing_BenchmarkService.ClientProtocol { body ) } - + internal func streamingBothWays( request: ClientRequest.Stream, options: CallOptions = .defaults, @@ -340,11 +340,11 @@ extension Grpc_Testing_BenchmarkService.ClientProtocol { @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkService.ClientProtocol { private let client: GRPCCore.GRPCClient - + internal init(wrapping client: GRPCCore.GRPCClient) { self.client = client } - + /// One request followed by one response. /// The server returns the client payload as-is. internal func unaryCall( @@ -363,7 +363,7 @@ internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkServi handler: body ) } - + /// Repeated sequence of one request followed by one response. /// Should be called streaming ping-pong /// The server returns the client payload as-is on each response @@ -383,7 +383,7 @@ internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkServi handler: body ) } - + /// Single-sided unbounded streaming from client to server /// The server returns the client payload as-is once the client does WritesDone internal func streamingFromClient( @@ -402,7 +402,7 @@ internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkServi handler: body ) } - + /// Single-sided unbounded streaming from server to client /// The server repeatedly returns the client payload as-is internal func streamingFromServer( @@ -421,7 +421,7 @@ internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkServi handler: body ) } - + /// Two-sided unbounded streaming between server to client /// Both sides send the content of their own choice to the other internal func streamingBothWays( diff --git a/Sources/performance-worker/Generated/grpc_testing_control.pb.swift b/Sources/performance-worker/Generated/grpc_testing_control.pb.swift index 44d5a5b61..969f5b561 100644 --- a/Sources/performance-worker/Generated/grpc_testing_control.pb.swift +++ b/Sources/performance-worker/Generated/grpc_testing_control.pb.swift @@ -743,8 +743,8 @@ struct Grpc_Testing_ScenarioResultSummary: @unchecked Sendable { // methods supported on all messages. /// Total number of operations per second over all clients. What is counted as 1 'operation' depends on the benchmark scenarios: - /// For unary benchmarks, an operation is processing of a single unary RPC. - /// For streaming benchmarks, an operation is processing of a single ping pong of request and response. + /// For unary benchmarks, an operation is processing of a single unary RPC. + /// For streaming benchmarks, an operation is processing of a single ping pong of request and response. var qps: Double { get {return _storage._qps} set {_uniqueStorage()._qps = newValue} @@ -757,8 +757,8 @@ struct Grpc_Testing_ScenarioResultSummary: @unchecked Sendable { } /// The total server cpu load based on system time across all server processes, expressed as percentage of a single cpu core. - /// For example, 85 implies 85% of a cpu core, 125 implies 125% of a cpu core. Since we are accumulating the cpu load across all the server - /// processes, the value could > 100 when there are multiple servers or a single server using multiple threads and cores. + /// For example, 85 implies 85% of a cpu core, 125 implies 125% of a cpu core. Since we are accumulating the cpu load across all the server + /// processes, the value could > 100 when there are multiple servers or a single server using multiple threads and cores. /// Same explanation for the total client cpu load below. var serverSystemTime: Double { get {return _storage._serverSystemTime} diff --git a/Sources/performance-worker/Generated/grpc_testing_worker_service.grpc.swift b/Sources/performance-worker/Generated/grpc_testing_worker_service.grpc.swift index 5b8a1de2b..2a702944f 100644 --- a/Sources/performance-worker/Generated/grpc_testing_worker_service.grpc.swift +++ b/Sources/performance-worker/Generated/grpc_testing_worker_service.grpc.swift @@ -91,7 +91,7 @@ internal protocol Grpc_Testing_WorkerServiceStreamingServiceProtocol: GRPCCore.R /// and once the shutdown has finished, the OK status is sent to terminate /// this RPC. func runServer(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// Start client with specified workload. /// First request sent specifies the ClientConfig followed by ClientStatus /// response. After that, a "Mark" can be sent anytime to request the latest @@ -99,10 +99,10 @@ internal protocol Grpc_Testing_WorkerServiceStreamingServiceProtocol: GRPCCore.R /// and once the shutdown has finished, the OK status is sent to terminate /// this RPC. func runClient(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// Just return the core count - unary call func coreCount(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// Quit this worker func quitWorker(request: ServerRequest.Stream) async throws -> ServerResponse.Stream } @@ -156,7 +156,7 @@ internal protocol Grpc_Testing_WorkerServiceServiceProtocol: Grpc_Testing_Worker /// and once the shutdown has finished, the OK status is sent to terminate /// this RPC. func runServer(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// Start client with specified workload. /// First request sent specifies the ClientConfig followed by ClientStatus /// response. After that, a "Mark" can be sent anytime to request the latest @@ -164,10 +164,10 @@ internal protocol Grpc_Testing_WorkerServiceServiceProtocol: Grpc_Testing_Worker /// and once the shutdown has finished, the OK status is sent to terminate /// this RPC. func runClient(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + /// Just return the core count - unary call func coreCount(request: ServerRequest.Single) async throws -> ServerResponse.Single - + /// Quit this worker func quitWorker(request: ServerRequest.Single) async throws -> ServerResponse.Single } @@ -179,7 +179,7 @@ extension Grpc_Testing_WorkerService.ServiceProtocol { let response = try await self.coreCount(request: ServerRequest.Single(stream: request)) return ServerResponse.Stream(single: response) } - + internal func quitWorker(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.quitWorker(request: ServerRequest.Single(stream: request)) return ServerResponse.Stream(single: response) diff --git a/Tests/GRPCHTTP2TransportTests/Generated/control.grpc.swift b/Tests/GRPCHTTP2TransportTests/Generated/control.grpc.swift index dbc205faf..9f4bdf534 100644 --- a/Tests/GRPCHTTP2TransportTests/Generated/control.grpc.swift +++ b/Tests/GRPCHTTP2TransportTests/Generated/control.grpc.swift @@ -91,11 +91,11 @@ extension ServiceDescriptor { @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) internal protocol ControlStreamingServiceProtocol: GRPCCore.RegistrableRPCService { func unary(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + func serverStream(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + func clientStream(request: ServerRequest.Stream) async throws -> ServerResponse.Stream - + func bidiStream(request: ServerRequest.Stream) async throws -> ServerResponse.Stream } @@ -146,11 +146,11 @@ extension Control.StreamingServiceProtocol { @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) internal protocol ControlServiceProtocol: Control.StreamingServiceProtocol { func unary(request: ServerRequest.Single) async throws -> ServerResponse.Single - + func serverStream(request: ServerRequest.Single) async throws -> ServerResponse.Stream - + func clientStream(request: ServerRequest.Stream) async throws -> ServerResponse.Single - + func bidiStream(request: ServerRequest.Stream) async throws -> ServerResponse.Stream } @@ -161,12 +161,12 @@ extension Control.ServiceProtocol { let response = try await self.unary(request: ServerRequest.Single(stream: request)) return ServerResponse.Stream(single: response) } - + internal func serverStream(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.serverStream(request: ServerRequest.Single(stream: request)) return response } - + internal func clientStream(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.clientStream(request: request) return ServerResponse.Stream(single: response) @@ -186,7 +186,7 @@ internal protocol ControlClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable - + func serverStream( request: ClientRequest.Single, serializer: some MessageSerializer, @@ -194,7 +194,7 @@ internal protocol ControlClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable - + func clientStream( request: ClientRequest.Stream, serializer: some MessageSerializer, @@ -202,7 +202,7 @@ internal protocol ControlClientProtocol: Sendable { options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable - + func bidiStream( request: ClientRequest.Stream, serializer: some MessageSerializer, @@ -227,7 +227,7 @@ extension Control.ClientProtocol { body ) } - + internal func serverStream( request: ClientRequest.Single, options: CallOptions = .defaults, @@ -241,7 +241,7 @@ extension Control.ClientProtocol { body ) } - + internal func clientStream( request: ClientRequest.Stream, options: CallOptions = .defaults, @@ -255,7 +255,7 @@ extension Control.ClientProtocol { body ) } - + internal func bidiStream( request: ClientRequest.Stream, options: CallOptions = .defaults, @@ -278,11 +278,11 @@ extension Control.ClientProtocol { @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) internal struct ControlClient: Control.ClientProtocol { private let client: GRPCCore.GRPCClient - + internal init(wrapping client: GRPCCore.GRPCClient) { self.client = client } - + internal func unary( request: ClientRequest.Single, serializer: some MessageSerializer, @@ -299,7 +299,7 @@ internal struct ControlClient: Control.ClientProtocol { handler: body ) } - + internal func serverStream( request: ClientRequest.Single, serializer: some MessageSerializer, @@ -316,7 +316,7 @@ internal struct ControlClient: Control.ClientProtocol { handler: body ) } - + internal func clientStream( request: ClientRequest.Stream, serializer: some MessageSerializer, @@ -333,7 +333,7 @@ internal struct ControlClient: Control.ClientProtocol { handler: body ) } - + internal func bidiStream( request: ClientRequest.Stream, serializer: some MessageSerializer,