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)
- CloseSend immediately after Send
- Minor 'invalid code' error output suggestion
- advancedtls package does not set VerifiedChains in TLSInfo.State HOT 5
- question: Bidirectional Streaming get error: rpc error: code = `Canceled` desc = `context canceled` HOT 6
- Delayed dns resolve after upgrade to v1.60.0 HOT 5
- channelz: SubChannel do not report their Target properly since 1.63 HOT 1
- xds: support LRS for all cluster types HOT 4
- Updating credentials of a running server HOT 5
- clusterimpl: update picker synchronously upon receipt of configuration update HOT 1
- cds: update picker synchronously upon receipt of configuration update
- rls: update picker synchronously upon receipt of configuration update
- Improve grpc-go/Documentation to clearly specify usage of `grpc.SetTrailer` function for adding metadata to send to client
- New ServerOption to set cancel insensitive "values" context. HOT 1
- Return the actual error from unary RPCs when `SendMsg()` returns `io.EOF` HOT 10
- protoc-gen-go-grpc: copy service comment to interfaces HOT 2
- Deprecate Dial and DialContext through a mechanism that doesn't trigger linters HOT 1
- Flaky test: 6/100K: Test/LRSClient HOT 2
- Docs: Document how to migrate from `Dial, DialContext, WithBlock, WithReturnConnectionError, FailOnNonTempDialError` to `NewClient` HOT 3
- Stop supporting 3 releases of Go HOT 2
- <invalid gRPC request method "PRI">, when happend grpc and http use sample port 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.