Skip to content

Commit a06ade3

Browse files
authored
Improve the names of a few commonly used APIs (#2014)
Motivation: Naming is important; it should be clear and concise. Modifications: The follow renames all offer more precise names: - Rename `server.run()` to `server.serve()` - Rename `server.stopListening()` to `server.beginGracefulShutdown()` - Rename `client.close()` to `client.beginGracefulShutdown()` Result: Clearer APIs
1 parent 63168d0 commit a06ade3

File tree

41 files changed

+116
-116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+116
-116
lines changed

Examples/v2/echo/Subcommands/Collect.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct Collect: AsyncParsableCommand {
5353
print("collect ← \(message.text)")
5454
}
5555

56-
client.close()
56+
client.beginGracefulShutdown()
5757
}
5858
}
5959
}

Examples/v2/echo/Subcommands/Expand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct Expand: AsyncParsableCommand {
5353
}
5454
}
5555

56-
client.close()
56+
client.beginGracefulShutdown()
5757
}
5858
}
5959
}

Examples/v2/echo/Subcommands/Get.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct Get: AsyncParsableCommand {
4848
print("get ← \(response.text)")
4949
}
5050

51-
client.close()
51+
client.beginGracefulShutdown()
5252
}
5353
}
5454
}

Examples/v2/echo/Subcommands/Serve.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct Serve: AsyncParsableCommand {
3636
)
3737

3838
try await withThrowingDiscardingTaskGroup { group in
39-
group.addTask { try await server.run() }
39+
group.addTask { try await server.serve() }
4040
if let address = try await server.listeningAddress {
4141
print("Echo listening on \(address)")
4242
}

Examples/v2/echo/Subcommands/Update.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct Update: AsyncParsableCommand {
5656
}
5757
}
5858

59-
client.close()
59+
client.beginGracefulShutdown()
6060
}
6161
}
6262
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct Greet: AsyncParsableCommand {
4242
}
4343

4444
defer {
45-
client.close()
45+
client.beginGracefulShutdown()
4646
}
4747

4848
let greeter = Helloworld_GreeterClient(wrapping: client)

Examples/v2/hello-world/Subcommands/Serve.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct Serve: AsyncParsableCommand {
3535
)
3636

3737
try await withThrowingDiscardingTaskGroup { group in
38-
group.addTask { try await server.run() }
38+
group.addTask { try await server.serve() }
3939
if let address = try await server.listeningAddress {
4040
print("Greeter listening on \(address)")
4141
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct GetFeature: AsyncParsableCommand {
6363
print("Found '\(feature.name)' at (\(self.latitude), \(self.longitude))")
6464
}
6565

66-
client.close()
66+
client.beginGracefulShutdown()
6767
}
6868
}
6969
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct ListFeatures: AsyncParsableCommand {
7979
}
8080
}
8181

82-
client.close()
82+
client.beginGracefulShutdown()
8383
}
8484

8585
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct RecordRoute: AsyncParsableCommand {
6868
"""
6969
print(text)
7070

71-
client.close()
71+
client.beginGracefulShutdown()
7272
}
7373
}
7474
}

0 commit comments

Comments
 (0)