-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a migration guide #2199
base: main
Are you sure you want to change the base?
Add a migration guide #2199
Conversation
Motivation: Moving from 1.x to 2.x isn't trivial. We should provide a guide for doing this. Modifications: - Add a guide for migrating client code and services - Add a script which can automate parts of this Result: Some guidance on migrating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing this up. I have a few questions here:
This seems to only outline a migration path for the simplest scenarios. What if an application author has multiple dependencies that use gRPC v1
- Do I have to wait until all of them vendored v1 so that I can depend on v2?
- If multiple dependencies vendor gRPC v1 then we should probably advise them rename/alias the modules otherwise we will have conflicts
# The path of the checkout. | ||
grpc_checkout_path="${grpc_checkout_dir}/grpc-swift-v1" | ||
# Version of grpc-swift to checkout. | ||
grpc_v1_tag="1.24.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be worth getting the latest tag by curling GH instead of hardcoding this here?
-exec sed -i '' 's/protoc-gen-grpc-swift/protoc-gen-grpc-swift-v1/g' {} + | ||
|
||
# Update the path of the protoc plugin so it aligns with the target name. | ||
log "Updating direcotry name for protoc-gen-grpc-swift-v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log "Updating direcotry name for protoc-gen-grpc-swift-v1" | |
log "Updating directory name for protoc-gen-grpc-swift-v1" |
|
||
1. Setup your package so it depends on a local copy of gRPC Swift 1.x and the | ||
upstream version of 2.x. | ||
2. Generate code for 2.x to alongside generated 1.x code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. Generate code for 2.x to alongside generated 1.x code. | |
2. Generate code for 2.x alongside generated 1.x code. |
upstream version of 2.x. | ||
2. Generate code for 2.x to alongside generated 1.x code. | ||
3. Incrementally migrate targets to 2.x. | ||
4. Remove the code generated for, and the dependency on 1.x. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4. Remove the code generated for, and the dependency on 1.x. | |
4. Remove the code generated for 1.x, and the dependency on 1.x. |
If you're reading this section then you're likely relying on metadata in your | ||
service. This means you need to implement the `ServiceProtocol` instead of the | ||
`SimpleServiceProtocol` and the transformations you need to apply are | ||
aren't well suited automation. The best approach is to conform your |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aren't well suited automation. The best approach is to conform your | |
aren't well suited for automation. The best approach is to conform your |
and return a `ServerResponse` or `StreamingServerResponse`. Request metadata is | ||
available on the request object. For single responses you can set initial and | ||
trailing metadata when you create the response. For streaming responses you can | ||
set initial metadata in the initializer and return trailing metadata from the | ||
closure you provide to the initializer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we link to the docs or tutorials in case this compressed version isn't enough to understand what's going on?
If a generated client is passed into the function then duplicate the function | ||
and replace the body of the new version with a `fatalError()`. You can also mark | ||
it as deprecated to help you find usages of the function. You'll now have two | ||
versions of the same function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like this paragraph and the one above beginning with "If the function is passed a generated client then duplicate it" should be merged.
is very similar, so you may not have to change any code. An important change to | ||
highlight is that for RPCs which stream their responses you must handle the | ||
response stream _within_ the closure passed to the client. By way of example, | ||
imagine the following server streaming RPC from 1.x: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might also be helpful to link to appropriate tutorials/examples/docs from here?
Motivation:
Moving from 1.x to 2.x isn't trivial. We should provide a guide for doing this.
Modifications:
Result:
Some guidance on migrating.