Skip to content

Commit ebcac53

Browse files
glbrnttgjcairo
andauthored
Update tutorials for beta 3 (#2165)
Motivation: We're going to tag beta 3 soon, so ensure the tutorials are up to date. Modifications: - Update tutorials Result: More up-to-date docs --------- Co-authored-by: Gus Cairo <[email protected]>
1 parent 3e75bbb commit ebcac53

15 files changed

+59
-87
lines changed

Diff for: README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ let package = Package(
3232
name: "foo-package",
3333
platforms: [.macOS("15.0")],
3434
dependencies: [
35-
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.2"),
36-
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.2"),
37-
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.2"),
35+
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.3"),
36+
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.3"),
37+
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.3"),
3838
],
3939
targets: [
4040
.executableTarget(

Diff for: Sources/GRPCCore/Documentation.docc/Tutorials/Hello-World/Hello-World.tutorial

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@Tutorial(time: 10) {
22
@XcodeRequirement(
3-
title: "Xcode 16 Beta 5+",
3+
title: "Xcode 16",
44
destination: "https://developer.apple.com/download/"
55
)
66

@@ -18,7 +18,7 @@
1818
repository by running the following command in a terminal:
1919

2020
```console
21-
git clone --branch 2.0.0-beta.2 https://github.com/grpc/grpc-swift
21+
git clone --branch 2.0.0-beta.3 https://github.com/grpc/grpc-swift
2222
```
2323

2424
You then need to change directory to the `Examples/hello-world` directory of the cloned

Diff for: Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec01-step07-description.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ let package = Package(
55
name: "RouteGuide",
66
platforms: [.macOS(.v15)],
77
dependencies: [
8-
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.2"),
9-
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.2"),
10-
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.2"),
8+
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.3"),
9+
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.3"),
10+
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.3"),
1111
],
1212
targets: []
1313
)

Diff for: Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec01-step08-description.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ let package = Package(
55
name: "RouteGuide",
66
platforms: [.macOS(.v15)],
77
dependencies: [
8-
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.2"),
9-
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.2"),
10-
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.2"),
8+
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.3"),
9+
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.3"),
10+
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.3"),
1111
],
1212
targets: [
1313
.executableTarget(

Diff for: Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec05-step00-package.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ let package = Package(
55
name: "RouteGuide",
66
platforms: [.macOS(.v15)],
77
dependencies: [
8-
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.2"),
9-
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.2"),
8+
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.3"),
9+
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.3"),
1010
],
1111
targets: [
1212
.executableTarget(

Diff for: Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec05-step01-package.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ let package = Package(
55
name: "RouteGuide",
66
platforms: [.macOS(.v15)],
77
dependencies: [
8-
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.2"),
9-
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.2"),
10-
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.2"),
8+
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.3"),
9+
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.3"),
10+
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.3"),
1111
],
1212
targets: [
1313
.executableTarget(

Diff for: Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec05-step02-package.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ let package = Package(
55
name: "RouteGuide",
66
platforms: [.macOS(.v15)],
77
dependencies: [
8-
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.2"),
9-
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.2"),
10-
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.2"),
8+
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.3"),
9+
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.3"),
10+
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.3"),
1111
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0"),
1212
],
1313
targets: [

Diff for: Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec06-step03-create-client.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import GRPCNIOTransportHTTP2
33

44
extension RouteGuide {
55
func runClient() async throws {
6-
let client = try GRPCClient(
6+
try await withGRPCClient(
77
transport: .http2NIOPosix(
88
target: .ipv4(host: "127.0.0.1", port: 31415),
99
transportSecurity: .plaintext
1010
)
11-
)
11+
) { client in
12+
// ...
13+
}
1214
}
1315
}

Diff for: Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec06-step04-run-client.swift

-15
This file was deleted.

Diff for: Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec06-step05-stub.swift

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ import GRPCNIOTransportHTTP2
33

44
extension RouteGuide {
55
func runClient() async throws {
6-
let client = try GRPCClient(
6+
try await withGRPCClient(
77
transport: .http2NIOPosix(
88
target: .ipv4(host: "127.0.0.1", port: 31415),
99
transportSecurity: .plaintext
1010
)
11-
)
12-
13-
async let _ = client.run()
14-
15-
let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
11+
) { client in
12+
let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
13+
}
1614
}
1715
}

Diff for: Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec06-step06-get-feature.swift

+5-7
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@ import GRPCNIOTransportHTTP2
33

44
extension RouteGuide {
55
func runClient() async throws {
6-
let client = try GRPCClient(
6+
try await withGRPCClient(
77
transport: .http2NIOPosix(
88
target: .ipv4(host: "127.0.0.1", port: 31415),
99
transportSecurity: .plaintext
1010
)
11-
)
12-
13-
async let _ = client.run()
14-
15-
let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
16-
try await self.getFeature(using: routeGuide)
11+
) { client in
12+
let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
13+
try await self.getFeature(using: routeGuide)
14+
}
1715
}
1816

1917
private func getFeature(using routeGuide: Routeguide_RouteGuide.Client) async throws {

Diff for: Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec06-step07-list-features.swift

+6-8
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@ import GRPCNIOTransportHTTP2
33

44
extension RouteGuide {
55
func runClient() async throws {
6-
let client = try GRPCClient(
6+
try await withGRPCClient(
77
transport: .http2NIOPosix(
88
target: .ipv4(host: "127.0.0.1", port: 31415),
99
transportSecurity: .plaintext
1010
)
11-
)
12-
13-
async let _ = client.run()
14-
15-
let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
16-
try await self.getFeature(using: routeGuide)
17-
try await self.listFeatures(using: routeGuide)
11+
) { client in
12+
let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
13+
try await self.getFeature(using: routeGuide)
14+
try await self.listFeatures(using: routeGuide)
15+
}
1816
}
1917

2018
private func getFeature(using routeGuide: Routeguide_RouteGuide.Client) async throws {

Diff for: Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec06-step08-record-route.swift

+7-9
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@ import GRPCNIOTransportHTTP2
33

44
extension RouteGuide {
55
func runClient() async throws {
6-
let client = try GRPCClient(
6+
try await withGRPCClient(
77
transport: .http2NIOPosix(
88
target: .ipv4(host: "127.0.0.1", port: 31415),
99
transportSecurity: .plaintext
1010
)
11-
)
12-
13-
async let _ = client.run()
14-
15-
let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
16-
try await self.getFeature(using: routeGuide)
17-
try await self.listFeatures(using: routeGuide)
18-
try await self.recordRoute(using: routeGuide)
11+
) { client in
12+
let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
13+
try await self.getFeature(using: routeGuide)
14+
try await self.listFeatures(using: routeGuide)
15+
try await self.recordRoute(using: routeGuide)
16+
}
1917
}
2018

2119
private func getFeature(using routeGuide: Routeguide_RouteGuide.Client) async throws {

Diff for: Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec06-step09-route-chat.swift

+8-10
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@ import GRPCNIOTransportHTTP2
33

44
extension RouteGuide {
55
func runClient() async throws {
6-
let client = try GRPCClient(
6+
try await withGRPCClient(
77
transport: .http2NIOPosix(
88
target: .ipv4(host: "127.0.0.1", port: 31415),
99
transportSecurity: .plaintext
1010
)
11-
)
12-
13-
async let _ = client.run()
14-
15-
let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
16-
try await self.getFeature(using: routeGuide)
17-
try await self.listFeatures(using: routeGuide)
18-
try await self.recordRoute(using: routeGuide)
19-
try await self.routeChat(using: routeGuide)
11+
) { client in
12+
let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
13+
try await self.getFeature(using: routeGuide)
14+
try await self.listFeatures(using: routeGuide)
15+
try await self.recordRoute(using: routeGuide)
16+
try await self.routeChat(using: routeGuide)
17+
}
2018
}
2119

2220
private func getFeature(using routeGuide: Routeguide_RouteGuide.Client) async throws {

Diff for: Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Route-Guide.tutorial

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@Tutorial(time: 30) {
22
@XcodeRequirement(
3-
title: "Xcode 16 Beta 6+",
3+
title: "Xcode 16",
44
destination: "https://developer.apple.com/download/"
55
)
66

@@ -401,20 +401,15 @@
401401
}
402402

403403
@Step {
404-
First we need to create a gRPC client for our stub, we're not using TLS so we
405-
use the `.plaintext` security transport and specify the server address and port
406-
we want to connect to.
404+
We need to create a gRPC client for our stub. gRPC provides a with-style helper to
405+
manage the lifecycle of the client and its transport so let's use that. We specify the
406+
transport to use and configure it appropriately. We're not using TLS so we use
407+
the `.plaintext` security transport and specify the server address and port we want to
408+
connect to.
407409

408410
@Code(name: "Sources/RouteGuide+Client.swift", file: "route-guide-sec06-step03-create-client.swift")
409411
}
410412

411-
@Step {
412-
To make RPCs using the client it needs to be running. Running the client will resolve the
413-
target address, start a load balancer and then maintain connections to the server.
414-
415-
@Code(name: "Sources/RouteGuide+Client.swift", file: "route-guide-sec06-step04-run-client.swift")
416-
}
417-
418413
@Step {
419414
We can now instantiate the stub with our `client` and call service methods.
420415

0 commit comments

Comments
 (0)