Skip to content

Add a migration guide #2199

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

Merged
merged 5 commits into from
Mar 3, 2025
Merged

Add a migration guide #2199

merged 5 commits into from
Mar 3, 2025

Conversation

glbrntt
Copy link
Collaborator

@glbrntt glbrntt commented Feb 18, 2025

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.

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.
@glbrntt glbrntt requested a review from gjcairo February 18, 2025 15:15
@glbrntt glbrntt added the semver/none No version bump required. label Feb 18, 2025
Copy link
Collaborator

@FranzBusch FranzBusch left a 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"
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we can just look at the tags though.

-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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log "Updating direcotry name for protoc-gen-grpc-swift-v1"
log "Updating directory name for protoc-gen-grpc-swift-v1"

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

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:
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what would be useful beyond the inline examples?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay fair, I was thinking it would be nice to have a link to the rest of the docs but this will likely be read in the context of the whole documentation anyways so finding the other docs should be easy.

@glbrntt
Copy link
Collaborator Author

glbrntt commented Feb 28, 2025

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 guide doesn't recommend that you keep the copy of v1. Indeed step 4 of the overview is to remove the copy of v1; It's only there to minimise the number of compilation errors during migration (this is also mentioned in the overview).

@glbrntt glbrntt requested a review from gjcairo February 28, 2025 14:33
Copy link
Collaborator

@gjcairo gjcairo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a nit

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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay fair, I was thinking it would be nice to have a link to the rest of the docs but this will likely be read in the context of the whole documentation anyways so finding the other docs should be easy.

@glbrntt glbrntt merged commit 87384f1 into grpc:main Mar 3, 2025
28 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/none No version bump required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants