瀏覽代碼

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 年之前
父節點
當前提交
7fad6011d6

+ 1 - 1
Tests/GRPCHTTP2TransportTests/Generated/control.grpc.swift

@@ -279,7 +279,7 @@ extension Control.ClientProtocol {
 internal struct ControlClient: Control.ClientProtocol {
 internal struct ControlClient: Control.ClientProtocol {
     private let client: GRPCCore.GRPCClient
     private let client: GRPCCore.GRPCClient
 
 
-    internal init(client: GRPCCore.GRPCClient) {
+    internal init(wrapping client: GRPCCore.GRPCClient) {
         self.client = client
         self.client = client
     }
     }
 
 

+ 2 - 2
Tests/GRPCHTTP2TransportTests/HTTP2TransportTests.swift

@@ -88,7 +88,7 @@ final class HTTP2TransportTests: XCTestCase {
         }
         }
 
 
         do {
         do {
-          let control = ControlClient(client: client)
+          let control = ControlClient(wrapping: client)
           try await execute(control, pair)
           try await execute(control, pair)
         } catch {
         } catch {
           XCTFail("Unexpected error: '\(error)' (\(pair))")
           XCTFail("Unexpected error: '\(error)' (\(pair))")
@@ -123,7 +123,7 @@ final class HTTP2TransportTests: XCTestCase {
         }
         }
 
 
         do {
         do {
-          let control = ControlClient(client: client)
+          let control = ControlClient(wrapping: client)
           try await execute(control, clientKind)
           try await execute(control, clientKind)
         } catch {
         } catch {
           XCTFail("Unexpected error: '\(error)' (\(clientKind))")
           XCTFail("Unexpected error: '\(error)' (\(clientKind))")