Browse Source

Change label in init of generated client (#2005)

Motivation:

In v2 a generated client stub for the echo service will have the
following init:
```swift
init(client: GRPCClient)
```

As client stubs are named `<Package>_<Service>Client`, the call site for
the echo service looks like:
```swift
let client: GRPCClient = …
let echo = Echo_EchoClient(client: client)
```
This reads badly.

Modifications:

- Change the label from `client:` to `wrapping client:` (since the
generated stub wraps the underlying `GRPCClient` to provide the
type-safe APIs).

Result:

The call site will look like:
```swift
let client: GRPCClient = …
let echo = Echo_EchoClient(wrapping: client)
```

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
Clinton Nkwocha 1 year ago
parent
commit
e08aa33330
1 changed files with 2 additions and 2 deletions
  1. 2 2
      Tests/GRPCProtobufCodeGenTests/ProtobufCodeGeneratorTests.swift

+ 2 - 2
Tests/GRPCProtobufCodeGenTests/ProtobufCodeGeneratorTests.swift

@@ -122,7 +122,7 @@ final class ProtobufCodeGeneratorTests: XCTestCase {
         internal struct Hello_World_GreeterClient: Hello_World_Greeter.ClientProtocol {
             private let client: GRPCCore.GRPCClient
             
-            internal init(client: GRPCCore.GRPCClient) {
+            internal init(wrapping client: GRPCCore.GRPCClient) {
                 self.client = client
             }
             
@@ -391,7 +391,7 @@ final class ProtobufCodeGeneratorTests: XCTestCase {
         package struct GreeterClient: Greeter.ClientProtocol {
           private let client: GRPCCore.GRPCClient
           
-          package init(client: GRPCCore.GRPCClient) {
+          package init(wrapping client: GRPCCore.GRPCClient) {
             self.client = client
           }