@@ -12,9 +12,9 @@ from 1.x to 2.x. You'll use the following strategy:
1212
13131 . Setup your package so it depends on a local copy of gRPC Swift 1.x and the
1414 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.
16163 . 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.
1818
1919You'll do this migration incrementally by staging in a local copy of gRPC Swift
20201.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.
284284If you're reading this section then you're likely relying on metadata in your
285285service. This means you need to implement the ` ServiceProtocol ` instead of the
286286` 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
288288service to the 1.x protocol and the 2.x protocol. Add conformance to the
289289` {Service}.ServiceProtocol ` where ` {Service} ` is the namespaced name of your
290290service (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
297297available on the request object. For single responses you can set initial and
298298trailing metadata when you create the response. For streaming responses you can
299299set 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.
301303
302304One important difference between this approach and the ` SimpleServiceProtocol `
303305(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()`.
384386Later you'll remove this function altogether.
385387
386388If 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:
388390
389391``` swift
390392var client: Foo_Bar_Baz.Client {
391393 fatalError (" TODO" )
392394}
393395```
394396
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-
400397Now you need to update the function to use the new client. For unary calls the API
401398is very similar, so you may not have to change any code. An important change to
402399highlight is that for RPCs which stream their responses you must handle the
0 commit comments