Skip to content

Commit 15ee677

Browse files
authored
Update examples (#13)
Motivation: The examples use the '.ipv4(host:)' target to resolve. We renamed this to '.ipv4(address:)' which is more accurate. However, the examples should most likely use '.dns(host:)' with "localhost" rather than the IPv4 address automatically as '.dns(host:)' is more likely to be used in real world applications. Modifications: - Change example clients from using '.ipv4(host: "127.0.0.1")' to '.dns(host: "localhost)'. Result: Fewer warnings, better examples
1 parent 8e4ecbd commit 15ee677

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

Examples/echo-metadata/Sources/ClientArguments.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ struct ClientArguments: ParsableArguments {
3030

3131
extension ClientArguments {
3232
var target: any ResolvableTarget {
33-
return .ipv4(host: "127.0.0.1", port: self.port)
33+
return .dns(host: "localhost", port: self.port)
3434
}
3535
}

Examples/echo/Sources/Subcommands/ClientArguments.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ struct ClientArguments: ParsableArguments {
3030

3131
extension ClientArguments {
3232
var target: any ResolvableTarget {
33-
return .ipv4(host: "127.0.0.1", port: self.port)
33+
return .dns(host: "localhost", port: self.port)
3434
}
3535
}

Examples/hello-world/Sources/Subcommands/Greet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct Greet: AsyncParsableCommand {
3131
func run() async throws {
3232
try await withGRPCClient(
3333
transport: .http2NIOPosix(
34-
target: .ipv4(host: "127.0.0.1", port: self.port),
34+
target: .dns(host: "localhost", port: self.port),
3535
transportSecurity: .plaintext
3636
)
3737
) { client in

Examples/route-guide/Sources/Subcommands/GetFeature.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct GetFeature: AsyncParsableCommand {
3939
func run() async throws {
4040
try await withGRPCClient(
4141
transport: .http2NIOPosix(
42-
target: .ipv4(host: "127.0.0.1", port: self.port),
42+
target: .dns(host: "localhost", port: self.port),
4343
transportSecurity: .plaintext
4444
)
4545
) { client in

Examples/route-guide/Sources/Subcommands/ListFeatures.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct ListFeatures: AsyncParsableCommand {
5353
func run() async throws {
5454
try await withGRPCClient(
5555
transport: .http2NIOPosix(
56-
target: .ipv4(host: "127.0.0.1", port: self.port),
56+
target: .dns(host: "localhost", port: self.port),
5757
transportSecurity: .plaintext
5858
)
5959
) { client in

Examples/route-guide/Sources/Subcommands/RecordRoute.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct RecordRoute: AsyncParsableCommand {
3232
func run() async throws {
3333
try await withGRPCClient(
3434
transport: .http2NIOPosix(
35-
target: .ipv4(host: "127.0.0.1", port: self.port),
35+
target: .dns(host: "localhost", port: self.port),
3636
transportSecurity: .plaintext
3737
)
3838
) { client in

Examples/route-guide/Sources/Subcommands/RouteChat.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct RouteChat: AsyncParsableCommand {
3232
func run() async throws {
3333
try await withGRPCClient(
3434
transport: .http2NIOPosix(
35-
target: .ipv4(host: "127.0.0.1", port: self.port),
35+
target: .dns(host: "localhost", port: self.port),
3636
transportSecurity: .plaintext
3737
)
3838
) { client in

0 commit comments

Comments
 (0)