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

Allow sending metadata #14

Closed
AlexITC opened this issue Mar 28, 2020 · 4 comments
Closed

Allow sending metadata #14

AlexITC opened this issue Mar 28, 2020 · 4 comments

Comments

@AlexITC
Copy link
Contributor

AlexITC commented Mar 28, 2020

Right now, the empty metadata is hardcoded, while it could be useful to support sending custom metadata.

On the scala client you can set up an interceptor which can add the metadata before a request is sent, this approach may be feasible on the scalajs client.

One idea to explore is to send cookies and try to setup envoy so that it transforms the cookies in grpc metadata, the drawback is that all request will include the same metadata, while sometimes it's useful to use different metadata per request.

@thesamet
Copy link
Contributor

thesamet commented May 2, 2020

I have squashed PR #20 and made some additional changes that were committed in 52f7fd4:

  • Code gen and core library moved to com.thesamet.scalapb.grpcweb
  • The generated code is inside an object name suffixed by GrpcWeb, i.e. MyServiceGrpcWeb:
  • The methods that take metadata and those that don't are generated inside a single trait. I preferred this over default parameters due to the having a default value for a metadata between two required args (request and responseObserver) is odd.
  • the new generator needs to run in addition to the existing generator (not to invoke it) for better modularity. If all generators did that, they couldn't be combined to a single run since they all would generate Scala code for message types.

Please check out the latest snapshot and provide feedback if we can close this issue.

Snapshots: https://oss.sonatype.org/content/repositories/snapshots/com/thesamet/scalapb/grpcweb/
Example updated: https://github.com/scalapb/scalapb-grpcweb/tree/master/example

@AlexITC
Copy link
Contributor Author

AlexITC commented May 2, 2020

From my tests, it looks good to me, I have submitted a small PR to update minor details

We'll try integrating this internally on a project and get back to you in the next week.

Thanks!

@thesamet
Copy link
Contributor

I believe this can be closed.

@AlexITC
Copy link
Contributor Author

AlexITC commented Nov 16, 2020

I confirm we have been using this successfully for months now.

Thanks!

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

No branches or pull requests

2 participants