@@ -12,9 +12,9 @@ from 1.x to 2.x. You'll use the following strategy:
12
12
13
13
1 . Setup your package so it depends on a local copy of gRPC Swift 1.x and the
14
14
upstream version of 2.x.
15
- 2 . Generate code for 2.x to alongside generated 1.x code.
15
+ 2 . Generate code for 2.x alongside generated 1.x code.
16
16
3 . Incrementally migrate targets to 2.x.
17
- 4 . Remove the code generated for, and the dependency on 1.x.
17
+ 4 . Remove the code generated for, and the dependency on, 1.x.
18
18
19
19
You'll do this migration incrementally by staging in a local copy of gRPC Swift
20
20
1.x and migrating client and service code on a per service basis. This approach
@@ -284,7 +284,7 @@ Repeat this until you've done all services in your package.
284
284
If you're reading this section then you're likely relying on metadata in your
285
285
service. This means you need to implement the ` ServiceProtocol ` instead of the
286
286
` SimpleServiceProtocol ` and the transformations you need to apply are
287
- aren't well suited automation. The best approach is to conform your
287
+ aren't well suited for automation. The best approach is to conform your
288
288
service to the 1.x protocol and the 2.x protocol. Add conformance to the
289
289
` {Service}.ServiceProtocol ` where ` {Service} ` is the namespaced name of your
290
290
service (if your service is called ` Baz ` and declared in the ` foo.bar ` Protocol
@@ -297,7 +297,9 @@ and return a `ServerResponse` or `StreamingServerResponse`. Request metadata is
297
297
available on the request object. For single responses you can set initial and
298
298
trailing metadata when you create the response. For streaming responses you can
299
299
set initial metadata in the initializer and return trailing metadata from the
300
- closure you provide to the initializer.
300
+ closure you provide to the initializer. This is demonstrated in the
301
+ [ 'echo-metadata'] ( https://github.com/grpc/grpc-swift/tree/main/Examples/echo-metadata )
302
+ example.
301
303
302
304
One important difference between this approach and the ` SimpleServiceProtocol `
303
305
(and 1.x) is that responses aren't completed until the body of the response has
@@ -384,19 +386,14 @@ Change the body of the function using the 1.x client to just `fatalError()`.
384
386
Later you'll remove this function altogether.
385
387
386
388
If the generated client is a stored type then add a new computed property
387
- returning an instance of it, the body can just call ` fatalError() ` for now:
389
+ returning an instance of it. the body can just call ` fatalError() ` for now:
388
390
389
391
``` swift
390
392
var client: Foo_Bar_Baz.Client {
391
393
fatalError (" TODO" )
392
394
}
393
395
```
394
396
395
- If a generated client is passed into the function then duplicate the function
396
- and replace the body of the new version with a ` fatalError() ` . You can also mark
397
- it as deprecated to help you find usages of the function. You'll now have two
398
- versions of the same function.
399
-
400
397
Now you need to update the function to use the new client. For unary calls the API
401
398
is very similar, so you may not have to change any code. An important change to
402
399
highlight is that for RPCs which stream their responses you must handle the
0 commit comments