Comments (11)
Here is a commit w/ an example of using metadata
for anyone interested.
Works nicely for things such as traceID
:
harlow/go-micro-services@221a67b
from grpc-go.
Please use metadata API to transmit your key-value pair. The example is
for unary rpc:
https://github.com/grpc/grpc-go/blob/master/test/end2end_test.go#L355
for streaming rpc:
https://github.com/grpc/grpc-go/blob/master/test/end2end_test.go#L504
For anyone looking for that example in the future, the above links won't work because master
has since changed and the line numbers don't match up. Here are the correct links:
For unary rpc:
Line 355 in 5149607
For streaming rpc:
Line 504 in 5149607
Tip: You can press y
when looking at a file to get a permalink:
from grpc-go.
Contexts are not for passing arbitrary bits of data from client to server. That's what the RPC message itself is for. There will probably be a mechanism for attaching bits of data to an RPC via a context (e.g. trace IDs), but it's going to be tightly controlled, and almost definitely not what you want to use.
from grpc-go.
Please use metadata API to transmit your key-value pair. The example is
for unary rpc:
https://github.com/grpc/grpc-go/blob/master/test/end2end_test.go#L355
for streaming rpc:
https://github.com/grpc/grpc-go/blob/master/test/end2end_test.go#L504
Cancellation is propagated to server only when it is needed.
On Sun, Mar 22, 2015 at 4:43 PM, David Symonds [email protected]
wrote:
Contexts are not for passing arbitrary bits of data from client to server.
That's what the RPC message itself is for. There will probably be a
mechanism for attaching bits of data to an RPC via a context (e.g. trace
IDs), but it's going to be tightly controlled, and almost definitely not
what you want to use.—
Reply to this email directly or view it on GitHub
#130 (comment).
from grpc-go.
There will probably be a mechanism for attaching bits of data to an RPC via a context (e.g. trace IDs), but it's going to be tightly controlled, and almost definitely not what you want to use.
@dsymonds any idea how far down the line this will be? It would be really nice to have Trace IDs as part of the context. It feels a bit clunky having to wrap all the Protos with Args/Req/Reply
messages just to pass the Tracer around.
Update
Example of using gRPC metadata context:
https://medium.com/@harlow/grpc-context-for-client-server-metadata-91cec8729424
from grpc-go.
On Sat, Apr 11, 2015 at 9:15 AM, Harlow Ward [email protected]
wrote:
There will probably be a mechanism for attaching bits of data to an RPC
via a context (e.g. trace IDs), but it's going to be tightly controlled,
and almost definitely not what you want to use.@dsymonds https://github.com/dsymonds any idea how far down the line
this will be? It would be really nice to have Trace IDs as part of the
context. It feels a bit clunky having to wrap all the Protos with
Args/Req/Reply messages just to pass the Tracer around.grpc-go does not allow users attach metadata to the context directly (grpc
will ignore that). Users are required to use metadata API to attach the
info (e.g., trace ID) to the context.—
Reply to this email directly or view it on GitHub
#130 (comment).
from grpc-go.
Is there a way to set the metadata from the generated protobuf client code?
from grpc-go.
Can you take a look at the examples in my very first reply on this issue on
how to set and receive metadata and see whether it answers your question?
Copied/pasted for your convenience:
Please use metadata API to transmit your key-value pair. The example is
*for unary rpc: *
https://github.com/grpc/grpc-go/blob/master/test/end2end_test.go#L355
https://github.com/grpc/grpc-go/blob/master/test/end2end_test.go#L355
for streaming rpc:
https://github.com/grpc/grpc-go/blob/master/test/end2end_test.go#L504
https://github.com/grpc/grpc-go/blob/master/test/end2end_test.go#L504
On Mon, Apr 27, 2015 at 10:12 AM, dramdass [email protected] wrote:
Is there a way to set the metadata from the generated protobuf client code?
—
Reply to this email directly or view it on GitHub
#130 (comment).
from grpc-go.
Thanks, Harlow!
On Fri, May 1, 2015 at 5:20 PM, Harlow Ward [email protected]
wrote:
Here is a commit for anyone interested in using the metadata. Works
nicely for things such as traceID:
harlow/go-micro-services@221a67b
harlow/go-micro-services@221a67b—
Reply to this email directly or view it on GitHub
#130 (comment).
from grpc-go.
@harlow you rock! Thank you.
from grpc-go.
@harlow just what I need! Tnank you!
from grpc-go.
Related Issues (20)
- encoding.GetCodec(proto.Name) broke in 1.66.0 HOT 7
- Create tests for two potential cardinality violation bugs HOT 1
- Backport #7571 to 1.66 once merged HOT 2
- Why is Metadata still being used instead of Attributes in clientconn.go? HOT 3
- Feature Request: Add Support for Generating Full Method Names List for Service-Level gRPC Interceptors
- xds: v1.66.0 regression in `xds.BootstrapContentsForTesting` HOT 11
- mem package & bufferPoolingThreshold HOT 3
- Generic Streams from protoc-gen-go-grpc are not detected by mock tools HOT 4
- Allow generated handlers to check the correct errors are returned at compile time HOT 1
- Flaky Test: xds/TestUnmarshalListener_WithUpdateValidatorFunc HOT 2
- gRPC server rarely returns UNAVAILABLE on seemingly successful requests HOT 13
- Flaky test: Test/ClientCloseReturnsEarlyWhenGoAwayWriteHangs HOT 4
- Where are the v1.66.1 release notes? HOT 3
- Uptick of FLOW_CONTROL_ERROR errors in CI after updating to 1.66.0 HOT 3
- google.golang.org/grpc v1.66.1 is missing a retraction HOT 4
- gRPC Server Sends RST_STREAM without trailers when TCP Reassembly occurs HOT 7
- 1.66.0 - increase in produced zero addresses HOT 9
- Flaky test: TestServeAndCloseDoNotRace
- panic: send on closed channel HOT 3
- mem.NewBuffer() should look at slice capacity? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grpc-go.