Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tutorials for beta 3 #2165

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 provide a with-style helper to
glbrntt marked this conversation as resolved.
Show resolved Hide resolved
manage the lifecycle of the client and its transport so let's use that. We specify the
transport to use which and configure it appropriately. We're not using TLS so we use
glbrntt marked this conversation as resolved.
Show resolved Hide resolved
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
Loading