Skip to content

Commit 5df133f

Browse files
authored
Merge branch 'main' into grpc-swift-protobuf_plugin_docs
2 parents 9e70d5c + 4c6357d commit 5df133f

File tree

145 files changed

+1651
-5860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+1651
-5860
lines changed

.github/workflows/pull_request.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,31 @@ jobs:
2626
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
2727
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
2828

29-
examples:
29+
construct-examples-matrix:
30+
name: Construct Examples matrix
31+
runs-on: ubuntu-latest
32+
outputs:
33+
examples-matrix: '${{ steps.generate-matrix.outputs.examples-matrix }}'
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
with:
38+
persist-credentials: false
39+
- id: generate-matrix
40+
run: echo "examples-matrix=$(curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT"
41+
env:
42+
MATRIX_LINUX_5_9_ENABLED: false
43+
MATRIX_LINUX_5_10_ENABLED: false
44+
MATRIX_LINUX_COMMAND: "./dev/build-examples.sh"
45+
MATRIX_LINUX_SETUP_COMMAND: "apt update && apt install -y protobuf-compiler && ./dev/build-examples.sh"
46+
47+
examples-matrix:
3048
name: Examples
31-
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
49+
needs: construct-examples-matrix
50+
uses: apple/swift-nio/.github/workflows/swift_test_matrix.yml@main
3251
with:
3352
name: "Examples"
34-
matrix_linux_5_9_enabled: false
35-
matrix_linux_5_10_enabled: false
36-
matrix_linux_command: "./dev/build-examples.sh"
53+
matrix_string: '${{ needs.construct-examples-matrix.outputs.examples-matrix }}'
3754

3855
benchmarks:
3956
name: Benchmarks

Examples/echo/Package.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ let package = Package(
2121
name: "echo",
2222
platforms: [.macOS("15.0")],
2323
dependencies: [
24-
.package(url: "https://github.com/grpc/grpc-swift.git", exact: "2.0.0-beta.2"),
25-
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", exact: "1.0.0-beta.2"),
26-
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", exact: "1.0.0-beta.2"),
24+
.package(url: "https://github.com/grpc/grpc-swift.git", branch: "main"),
25+
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", branch: "main"),
26+
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", branch: "main"),
2727
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"),
2828
],
2929
targets: [
@@ -34,6 +34,9 @@ let package = Package(
3434
.product(name: "GRPCNIOTransportHTTP2", package: "grpc-swift-nio-transport"),
3535
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
3636
.product(name: "ArgumentParser", package: "swift-argument-parser"),
37+
],
38+
plugins: [
39+
.plugin(name: "GRPCProtobufGenerator", package: "grpc-swift-protobuf")
3740
]
3841
)
3942
]

Examples/echo/Sources/Generated/echo.grpc.swift

Lines changed: 0 additions & 994 deletions
This file was deleted.

Examples/echo/Sources/Generated/echo.pb.swift

Lines changed: 0 additions & 129 deletions
This file was deleted.

Examples/echo/Sources/Protos/echo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../dev/protos/examples/echo/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"generate": {
3+
"clients": true,
4+
"servers": true,
5+
"messages": true
6+
}
7+
}

Examples/echo/Sources/Subcommands/Collect.swift

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,12 @@ struct Collect: AsyncParsableCommand {
2727
var arguments: ClientArguments
2828

2929
func run() async throws {
30-
let client = GRPCClient(
31-
transport: try .http2NIOPosix(
30+
try await withGRPCClient(
31+
transport: .http2NIOPosix(
3232
target: self.arguments.target,
3333
transportSecurity: .plaintext
3434
)
35-
)
36-
37-
try await withThrowingDiscardingTaskGroup { group in
38-
group.addTask {
39-
try await client.run()
40-
}
41-
35+
) { client in
4236
let echo = Echo_Echo.Client(wrapping: client)
4337

4438
for _ in 0 ..< self.arguments.repetitions {
@@ -50,8 +44,6 @@ struct Collect: AsyncParsableCommand {
5044
}
5145
print("collect ← \(message.text)")
5246
}
53-
54-
client.beginGracefulShutdown()
5547
}
5648
}
5749
}

Examples/echo/Sources/Subcommands/Expand.swift

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,12 @@ struct Expand: AsyncParsableCommand {
2727
var arguments: ClientArguments
2828

2929
func run() async throws {
30-
let client = GRPCClient(
31-
transport: try .http2NIOPosix(
30+
try await withGRPCClient(
31+
transport: .http2NIOPosix(
3232
target: self.arguments.target,
3333
transportSecurity: .plaintext
3434
)
35-
)
36-
37-
try await withThrowingDiscardingTaskGroup { group in
38-
group.addTask {
39-
try await client.run()
40-
}
41-
35+
) { client in
4236
let echo = Echo_Echo.Client(wrapping: client)
4337

4438
for _ in 0 ..< self.arguments.repetitions {
@@ -50,8 +44,6 @@ struct Expand: AsyncParsableCommand {
5044
}
5145
}
5246
}
53-
54-
client.beginGracefulShutdown()
5547
}
5648
}
5749
}

Examples/echo/Sources/Subcommands/Get.swift

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,12 @@ struct Get: AsyncParsableCommand {
2525
var arguments: ClientArguments
2626

2727
func run() async throws {
28-
let client = GRPCClient(
29-
transport: try .http2NIOPosix(
28+
try await withGRPCClient(
29+
transport: .http2NIOPosix(
3030
target: self.arguments.target,
3131
transportSecurity: .plaintext
3232
)
33-
)
34-
35-
try await withThrowingDiscardingTaskGroup { group in
36-
group.addTask {
37-
try await client.run()
38-
}
39-
33+
) { client in
4034
let echo = Echo_Echo.Client(wrapping: client)
4135

4236
for _ in 0 ..< self.arguments.repetitions {
@@ -45,8 +39,6 @@ struct Get: AsyncParsableCommand {
4539
let response = try await echo.get(message)
4640
print("get ← \(response.text)")
4741
}
48-
49-
client.beginGracefulShutdown()
5042
}
5143
}
5244
}

Examples/echo/Sources/Subcommands/Update.swift

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,12 @@ struct Update: AsyncParsableCommand {
2727
var arguments: ClientArguments
2828

2929
func run() async throws {
30-
let client = GRPCClient(
31-
transport: try .http2NIOPosix(
30+
try await withGRPCClient(
31+
transport: .http2NIOPosix(
3232
target: self.arguments.target,
3333
transportSecurity: .plaintext
3434
)
35-
)
36-
37-
try await withThrowingDiscardingTaskGroup { group in
38-
group.addTask {
39-
try await client.run()
40-
}
41-
35+
) { client in
4236
let echo = Echo_Echo.Client(wrapping: client)
4337

4438
for _ in 0 ..< self.arguments.repetitions {
@@ -53,8 +47,6 @@ struct Update: AsyncParsableCommand {
5347
}
5448
}
5549
}
56-
57-
client.beginGracefulShutdown()
5850
}
5951
}
6052
}

0 commit comments

Comments
 (0)