salesforce / grpc-java-contrib

Useful extensions for the grpc-java library
BSD 3-Clause "New" or "Revised" License
220 stars 34 forks source link

Feature/context #54

Closed rmichela closed 6 years ago

codecov[bot] commented 6 years ago

Codecov Report

Merging #54 into master will increase coverage by 4.98%. The diff coverage is 83.89%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #54      +/-   ##
============================================
+ Coverage     53.26%   58.25%   +4.98%     
- Complexity      138      188      +50     
============================================
  Files            34       40       +6     
  Lines           766      915     +149     
  Branches         43       67      +24     
============================================
+ Hits            408      533     +125     
- Misses          341      359      +18     
- Partials         17       23       +6
Impacted Files Coverage Δ Complexity Δ
...alesforce/grpc/contrib/context/AmbientContext.java 77.5% <77.5%> (ø) 22 <22> (?)
...context/AmbientContextFreezeServerInterceptor.java 80% <80%> (ø) 2 <2> (?)
...ntrib/context/AmbientContextServerInterceptor.java 86.66% <86.66%> (ø) 9 <9> (?)
...ntext/AmbientContextEnforcerClientInterceptor.java 87.5% <87.5%> (ø) 7 <7> (?)
...ntext/AmbientContextEnforcerServerInterceptor.java 87.5% <87.5%> (ø) 7 <7> (?)
...ntrib/context/AmbientContextClientInterceptor.java 88.88% <88.88%> (ø) 3 <3> (?)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0ebb44f...c41f503. Read the comment docs.

cbornet commented 6 years ago

I understand that the AmbientContext is a helper to get Metadata values from endpoint methods, is that correct ? Do you know if there's a way to add metadata values to responses ?

rmichela commented 6 years ago

Request trailers can contain additional Metadata, although trailer metadata isn't readily accessible from stub API. Individual response messages cannot have their own metadata.

cbornet commented 6 years ago

The question is: can I get metadata in a Rxgrpc stub API from the Ambient context ?

rmichela commented 6 years ago

I haven't tried that yet, but it should work in theory. You would have to add the ambient context interceptors when using ManagedChannelBuilder and ServerBuilder. Since ambient context leverages the standard grpc Context, and RxGrpc correctly handles the Context, it should "just work".

cbornet commented 6 years ago

Great ! This can be very helpful !