Hacker News new | ask | show | jobs
by nepthar 971 days ago
I am blown away that this is not already part of gRPC. A lifetime ago, I worked on twitter's version of this sort of thing (thrift/finagle) and I assumed it was standard.
2 comments

Both the context and message metadata are already part of gRPC. The gRPC system also allows for server [2] and client message interceptors. Essentially this konig-kontext library provides a interceptor implementations, e.g., [3], that uses their hard-coded key for your serializable context that gets read/written from a gRPC header. The context provided by konig-kontext within your code is a wrapper around the existing gRPC Context [1].

The library is convenient for sure, but I feel that if you had a need to propagate context within gRPC, you'd probably already discovered the API and implemented propagation with your own header keys.

[1] https://grpc.github.io/grpc-java/javadoc/io/grpc/Context.htm...

[2] https://grpc.github.io/grpc-java/javadoc/io/grpc/ServerInter...

[3] https://github.com/konigsoftware/konig-kontext/blob/84faa627...

It's HTTP/2, so has headers and trailers. That's where most people put the metadata.