Skip to content
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

cosmos-sdk-protos: add grpc-transport feature #230

Merged
merged 3 commits into from
May 16, 2022

Conversation

tony-iqlusion
Copy link
Member

Closes #226

Adds an on-by-default grpc-transport feature which enables the corresponding transport feature in tonic. The main use case is supporting gRPC in WASM environments.

To make this work with generated code, the generated protos are patched to feature-gate the tonic::transport-dependent code.

Closes #226

Adds an on-by-default `grpc-transport` feature which enables the
corresponding `transport` feature in `tonic`.

To make this work with generated code, the generated protos are patched
to feature-gate the `tonic::transport`-dependent code.
Comment on lines 437 to 451
let patched_contents =
contents.replace(TONIC_CLIENT_ATTRIBUTE, &GRPC_CLIENT_ATTRIBUTES.join("\n"));
let contents = contents.replace(TONIC_CLIENT_ATTRIBUTE, &GRPC_CLIENT_ATTRIBUTES.join("\n"));

fs::write(dest, patched_contents)
// Feature gate gRPC client impl blocks which rely on `tonic::transport`
let contents = Regex::new(TONIC_CLIENT_IMPL)
.unwrap()
.replace_all(&contents, TONIC_CLIENT_REPLACEMENT);

// Write output to destination
fs::write(dest, &*contents)
Copy link
Member Author

Choose a reason for hiding this comment

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

It might be worth refactoring how these transformations are applied to the generated protos, making it into an folding iterator over Regex and replacement string tuples that applies successive transformations

@tony-iqlusion
Copy link
Member Author

Went ahead and did the cleanup I proposed regarding the regex substitutions on the output

@tony-iqlusion tony-iqlusion force-pushed the cargo-sdk-proto/grpc-transport-feature branch from a9ca34f to 7a3d5f0 Compare May 16, 2022 19:16
@tony-iqlusion tony-iqlusion merged commit 5bff4b8 into main May 16, 2022
@tony-iqlusion tony-iqlusion deleted the cargo-sdk-proto/grpc-transport-feature branch May 16, 2022 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support cosmos-sdk-proto without transport feature of tonic
1 participant