From 851e9f6da4b34077e2fae75d2a44edd0f9af9055 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Thu, 7 Aug 2025 17:25:24 +0100 Subject: [PATCH] Update examples 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 --- Examples/echo-metadata/Sources/ClientArguments.swift | 2 +- Examples/echo/Sources/Subcommands/ClientArguments.swift | 2 +- Examples/hello-world/Sources/Subcommands/Greet.swift | 2 +- Examples/route-guide/Sources/Subcommands/GetFeature.swift | 2 +- Examples/route-guide/Sources/Subcommands/ListFeatures.swift | 2 +- Examples/route-guide/Sources/Subcommands/RecordRoute.swift | 2 +- Examples/route-guide/Sources/Subcommands/RouteChat.swift | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Examples/echo-metadata/Sources/ClientArguments.swift b/Examples/echo-metadata/Sources/ClientArguments.swift index 9aa237f6..a4f67252 100644 --- a/Examples/echo-metadata/Sources/ClientArguments.swift +++ b/Examples/echo-metadata/Sources/ClientArguments.swift @@ -30,6 +30,6 @@ struct ClientArguments: ParsableArguments { extension ClientArguments { var target: any ResolvableTarget { - return .ipv4(host: "127.0.0.1", port: self.port) + return .dns(host: "localhost", port: self.port) } } diff --git a/Examples/echo/Sources/Subcommands/ClientArguments.swift b/Examples/echo/Sources/Subcommands/ClientArguments.swift index afa8cbd4..c8619e96 100644 --- a/Examples/echo/Sources/Subcommands/ClientArguments.swift +++ b/Examples/echo/Sources/Subcommands/ClientArguments.swift @@ -30,6 +30,6 @@ struct ClientArguments: ParsableArguments { extension ClientArguments { var target: any ResolvableTarget { - return .ipv4(host: "127.0.0.1", port: self.port) + return .dns(host: "localhost", port: self.port) } } diff --git a/Examples/hello-world/Sources/Subcommands/Greet.swift b/Examples/hello-world/Sources/Subcommands/Greet.swift index 643c9079..c86320a4 100644 --- a/Examples/hello-world/Sources/Subcommands/Greet.swift +++ b/Examples/hello-world/Sources/Subcommands/Greet.swift @@ -31,7 +31,7 @@ struct Greet: AsyncParsableCommand { func run() async throws { try await withGRPCClient( transport: .http2NIOPosix( - target: .ipv4(host: "127.0.0.1", port: self.port), + target: .dns(host: "localhost", port: self.port), transportSecurity: .plaintext ) ) { client in diff --git a/Examples/route-guide/Sources/Subcommands/GetFeature.swift b/Examples/route-guide/Sources/Subcommands/GetFeature.swift index 6ea6a12b..1ffd2d99 100644 --- a/Examples/route-guide/Sources/Subcommands/GetFeature.swift +++ b/Examples/route-guide/Sources/Subcommands/GetFeature.swift @@ -39,7 +39,7 @@ struct GetFeature: AsyncParsableCommand { func run() async throws { try await withGRPCClient( transport: .http2NIOPosix( - target: .ipv4(host: "127.0.0.1", port: self.port), + target: .dns(host: "localhost", port: self.port), transportSecurity: .plaintext ) ) { client in diff --git a/Examples/route-guide/Sources/Subcommands/ListFeatures.swift b/Examples/route-guide/Sources/Subcommands/ListFeatures.swift index be6d754d..b58a6e29 100644 --- a/Examples/route-guide/Sources/Subcommands/ListFeatures.swift +++ b/Examples/route-guide/Sources/Subcommands/ListFeatures.swift @@ -53,7 +53,7 @@ struct ListFeatures: AsyncParsableCommand { func run() async throws { try await withGRPCClient( transport: .http2NIOPosix( - target: .ipv4(host: "127.0.0.1", port: self.port), + target: .dns(host: "localhost", port: self.port), transportSecurity: .plaintext ) ) { client in diff --git a/Examples/route-guide/Sources/Subcommands/RecordRoute.swift b/Examples/route-guide/Sources/Subcommands/RecordRoute.swift index 7a652206..aed4b1ae 100644 --- a/Examples/route-guide/Sources/Subcommands/RecordRoute.swift +++ b/Examples/route-guide/Sources/Subcommands/RecordRoute.swift @@ -32,7 +32,7 @@ struct RecordRoute: AsyncParsableCommand { func run() async throws { try await withGRPCClient( transport: .http2NIOPosix( - target: .ipv4(host: "127.0.0.1", port: self.port), + target: .dns(host: "localhost", port: self.port), transportSecurity: .plaintext ) ) { client in diff --git a/Examples/route-guide/Sources/Subcommands/RouteChat.swift b/Examples/route-guide/Sources/Subcommands/RouteChat.swift index ba6d9242..1888b099 100644 --- a/Examples/route-guide/Sources/Subcommands/RouteChat.swift +++ b/Examples/route-guide/Sources/Subcommands/RouteChat.swift @@ -32,7 +32,7 @@ struct RouteChat: AsyncParsableCommand { func run() async throws { try await withGRPCClient( transport: .http2NIOPosix( - target: .ipv4(host: "127.0.0.1", port: self.port), + target: .dns(host: "localhost", port: self.port), transportSecurity: .plaintext ) ) { client in