Skip to content

Commit

Permalink
Update tutorials for beta 3 (#2165)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
glbrntt and gjcairo authored Jan 17, 2025
1 parent 3e75bbb commit ebcac53
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 87 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ let package = Package(
name: "foo-package",
platforms: [.macOS("15.0")],
dependencies: [
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.3"),
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.3"),
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.3"),
],
targets: [
.executableTarget(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@Tutorial(time: 10) {
@XcodeRequirement(
title: "Xcode 16 Beta 5+",
title: "Xcode 16",
destination: "https://developer.apple.com/download/"
)

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

```console
git clone --branch 2.0.0-beta.2 https://github.com/grpc/grpc-swift
git clone --branch 2.0.0-beta.3 https://github.com/grpc/grpc-swift
```

You then need to change directory to the `Examples/hello-world` directory of the cloned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ let package = Package(
name: "RouteGuide",
platforms: [.macOS(.v15)],
dependencies: [
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.3"),
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.3"),
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.3"),
],
targets: []
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ let package = Package(
name: "RouteGuide",
platforms: [.macOS(.v15)],
dependencies: [
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.3"),
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.3"),
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.3"),
],
targets: [
.executableTarget(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ let package = Package(
name: "RouteGuide",
platforms: [.macOS(.v15)],
dependencies: [
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.3"),
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.3"),
],
targets: [
.executableTarget(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ let package = Package(
name: "RouteGuide",
platforms: [.macOS(.v15)],
dependencies: [
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.3"),
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.3"),
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.3"),
],
targets: [
.executableTarget(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ let package = Package(
name: "RouteGuide",
platforms: [.macOS(.v15)],
dependencies: [
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-beta.3"),
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-beta.3"),
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-beta.3"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0"),
],
targets: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import GRPCNIOTransportHTTP2

extension RouteGuide {
func runClient() async throws {
let client = try GRPCClient(
try await withGRPCClient(
transport: .http2NIOPosix(
target: .ipv4(host: "127.0.0.1", port: 31415),
transportSecurity: .plaintext
)
)
) { client in
// ...
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import GRPCNIOTransportHTTP2

extension RouteGuide {
func runClient() async throws {
let client = try GRPCClient(
try await withGRPCClient(
transport: .http2NIOPosix(
target: .ipv4(host: "127.0.0.1", port: 31415),
transportSecurity: .plaintext
)
)

async let _ = client.run()

let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
) { client in
let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import GRPCNIOTransportHTTP2

extension RouteGuide {
func runClient() async throws {
let client = try GRPCClient(
try await withGRPCClient(
transport: .http2NIOPosix(
target: .ipv4(host: "127.0.0.1", port: 31415),
transportSecurity: .plaintext
)
)

async let _ = client.run()

let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
try await self.getFeature(using: routeGuide)
) { client in
let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
try await self.getFeature(using: routeGuide)
}
}

private func getFeature(using routeGuide: Routeguide_RouteGuide.Client) async throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@ import GRPCNIOTransportHTTP2

extension RouteGuide {
func runClient() async throws {
let client = try GRPCClient(
try await withGRPCClient(
transport: .http2NIOPosix(
target: .ipv4(host: "127.0.0.1", port: 31415),
transportSecurity: .plaintext
)
)

async let _ = client.run()

let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
try await self.getFeature(using: routeGuide)
try await self.listFeatures(using: routeGuide)
) { client in
let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
try await self.getFeature(using: routeGuide)
try await self.listFeatures(using: routeGuide)
}
}

private func getFeature(using routeGuide: Routeguide_RouteGuide.Client) async throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ import GRPCNIOTransportHTTP2

extension RouteGuide {
func runClient() async throws {
let client = try GRPCClient(
try await withGRPCClient(
transport: .http2NIOPosix(
target: .ipv4(host: "127.0.0.1", port: 31415),
transportSecurity: .plaintext
)
)

async let _ = client.run()

let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
try await self.getFeature(using: routeGuide)
try await self.listFeatures(using: routeGuide)
try await self.recordRoute(using: routeGuide)
) { client in
let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
try await self.getFeature(using: routeGuide)
try await self.listFeatures(using: routeGuide)
try await self.recordRoute(using: routeGuide)
}
}

private func getFeature(using routeGuide: Routeguide_RouteGuide.Client) async throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ import GRPCNIOTransportHTTP2

extension RouteGuide {
func runClient() async throws {
let client = try GRPCClient(
try await withGRPCClient(
transport: .http2NIOPosix(
target: .ipv4(host: "127.0.0.1", port: 31415),
transportSecurity: .plaintext
)
)

async let _ = client.run()

let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
try await self.getFeature(using: routeGuide)
try await self.listFeatures(using: routeGuide)
try await self.recordRoute(using: routeGuide)
try await self.routeChat(using: routeGuide)
) { client in
let routeGuide = Routeguide_RouteGuide.Client(wrapping: client)
try await self.getFeature(using: routeGuide)
try await self.listFeatures(using: routeGuide)
try await self.recordRoute(using: routeGuide)
try await self.routeChat(using: routeGuide)
}
}

private func getFeature(using routeGuide: Routeguide_RouteGuide.Client) async throws {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@Tutorial(time: 30) {
@XcodeRequirement(
title: "Xcode 16 Beta 6+",
title: "Xcode 16",
destination: "https://developer.apple.com/download/"
)

Expand Down Expand Up @@ -401,20 +401,15 @@
}

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

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

@Step {
To make RPCs using the client it needs to be running. Running the client will resolve the
target address, start a load balancer and then maintain connections to the server.

@Code(name: "Sources/RouteGuide+Client.swift", file: "route-guide-sec06-step04-run-client.swift")
}

@Step {
We can now instantiate the stub with our `client` and call service methods.

Expand Down

0 comments on commit ebcac53

Please sign in to comment.