-
Notifications
You must be signed in to change notification settings - Fork 80
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
Support headers #40
Support headers #40
Conversation
Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
LGTM |
I tested this and have code to update the |
Just a nit, does it make sense to call this re: using this for namespaces. |
This can be called in many different ways, but the concept remains the same - send arbitrary data with a request. IMO name 'headers' make the intention of this a bit clearer for a user - pass an extra information with a request, similarly to what http headers are used for.
That would work, but you'd need to modify each request to add 'namespace' field to use namespaces.
So it'd be nice to use the same mechanism for ttrpc as well. |
Headers are items that are sent at the beginning of a request. These really aren't headers. I'm not sure I agree with stuffing data into the protocol that changes the behavior of the rpc endpoint.. but I guess that's not really an argument for this repo. Being able to attach metadata to a request does make sense though, e.g. for distributed tracing. |
Changing the name from headers to metadata sounds like a good idea
Michael Crosby
… On May 24, 2019, at 6:56 PM, Brian Goff ***@***.***> wrote:
Headers are items that are sent at the beginning of a request. These really aren't headers.
Metadata would be fitting, IMO. Also similar to grpc.
I'm not sure I agree with stuffing data into the protocol that changes the behavior of the rpc endpoint.. but I guess that's not really an argument for this repo.
Being able to attach metadata to a request does make sense though, e.g. for distributed tracing.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@crosbymichael @cpuguy83 done |
Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM |
import "context" | ||
|
||
// Metadata represents the key-value pairs (similar to http.Header) to be passed to ttrpc server from a client. | ||
type Metadata map[string]StringList |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type is not well supported by protobuf.
"testing" | ||
) | ||
|
||
func TestMetadata_Get(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use underscores in test names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOT LGTM
Sorry for coming in late here, but this needs a few fixes on the protocol serialization/support.
- Metadata needs to be defined as part of types.go. That documents the entire protocol. If there are metadata helpers, you can include them in a separate file.
- The StringList approach is incompatible with the way grpc represents maps. You really need to have a list of key-value pairs. This does repeat keys, but repeated keys is not a common use case, so its not worth breaking generating compatibility. I'd recommend separating the serialization types from the user types.
- GetMetadataValue needs to return multiple strings, so be compatible with grpc's headers, which allow multiple values.
4. We should use a model closer to net/http headers than the metadata interface in grpc-go. net/http headers let's you control set vs add, etc.User type looks good here.
We should get another PR on this before we can't go back on it.
@@ -61,6 +61,7 @@ func (tc *testingClient) Test(ctx context.Context, req *testPayload) (*testPaylo | |||
type testPayload struct { | |||
Foo string `protobuf:"bytes,1,opt,name=foo,proto3"` | |||
Deadline int64 `protobuf:"varint,2,opt,name=deadline,proto3"` | |||
Metadata string `protobuf:"bytes,3,opt,name=metadata,proto3"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this line adds any value.
#43 covers the concerns here. |
full diff: containerd/ttrpc@699c4e4...1fb3814 changes included: - containerd/ttrpc#37 Handle EOF to prevent file descriptor leak - containerd/ttrpc#38 Improve connection error handling - containerd/ttrpc#40 Support headers - containerd/ttrpc#41 Add client and server unary interceptors - containerd/ttrpc#42 Refactor close handling for ttrpc clients - containerd/ttrpc#43 metadata as KeyValue type Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
full diff: containerd/ttrpc@699c4e4...92c8520 changes: - containerd/ttrpc#37 Handle EOF to prevent file descriptor leak - containerd/ttrpc#38 Improve connection error handling - containerd/ttrpc#40 Support headers - containerd/ttrpc#41 Add client and server unary interceptors - containerd/ttrpc#43 metadata as KeyValue type - containerd/ttrpc#42 Refactor close handling for ttrpc clients - containerd/ttrpc#44 Fix method full name generation - containerd/ttrpc#46 Client.Call(): do not return error if no Status is set (gRPC v1.23 and up) - containerd/ttrpc#49 Handle ok status Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
full diff: containerd/ttrpc@699c4e4...92c8520 changes: - containerd/ttrpc#37 Handle EOF to prevent file descriptor leak - containerd/ttrpc#38 Improve connection error handling - containerd/ttrpc#40 Support headers - containerd/ttrpc#41 Add client and server unary interceptors - containerd/ttrpc#43 metadata as KeyValue type - containerd/ttrpc#42 Refactor close handling for ttrpc clients - containerd/ttrpc#44 Fix method full name generation - containerd/ttrpc#46 Client.Call(): do not return error if no Status is set (gRPC v1.23 and up) - containerd/ttrpc#49 Handle ok status Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 8769255d1bb9c469d4f2966e7e9869a9f126f9e9 Component: engine
full diff: containerd/ttrpc@699c4e4...92c8520 changes: - containerd/ttrpc#37 Handle EOF to prevent file descriptor leak - containerd/ttrpc#38 Improve connection error handling - containerd/ttrpc#40 Support headers - containerd/ttrpc#41 Add client and server unary interceptors - containerd/ttrpc#43 metadata as KeyValue type - containerd/ttrpc#42 Refactor close handling for ttrpc clients - containerd/ttrpc#44 Fix method full name generation - containerd/ttrpc#46 Client.Call(): do not return error if no Status is set (gRPC v1.23 and up) - containerd/ttrpc#49 Handle ok status Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit 8769255) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
full diff: containerd/ttrpc@699c4e4...92c8520 changes: - containerd/ttrpc#37 Handle EOF to prevent file descriptor leak - containerd/ttrpc#38 Improve connection error handling - containerd/ttrpc#40 Support headers - containerd/ttrpc#41 Add client and server unary interceptors - containerd/ttrpc#43 metadata as KeyValue type - containerd/ttrpc#42 Refactor close handling for ttrpc clients - containerd/ttrpc#44 Fix method full name generation - containerd/ttrpc#46 Client.Call(): do not return error if no Status is set (gRPC v1.23 and up) - containerd/ttrpc#49 Handle ok status Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit 8769255d1bb9c469d4f2966e7e9869a9f126f9e9) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 525e8ed3febff46d07cb01961601824b5f8b301b Component: engine
full diff: containerd/ttrpc@699c4e4...92c8520 changes: - containerd/ttrpc#37 Handle EOF to prevent file descriptor leak - containerd/ttrpc#38 Improve connection error handling - containerd/ttrpc#40 Support headers - containerd/ttrpc#41 Add client and server unary interceptors - containerd/ttrpc#43 metadata as KeyValue type - containerd/ttrpc#42 Refactor close handling for ttrpc clients - containerd/ttrpc#44 Fix method full name generation - containerd/ttrpc#46 Client.Call(): do not return error if no Status is set (gRPC v1.23 and up) - containerd/ttrpc#49 Handle ok status Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Signed-off-by: zach <Zachary.Joyner@linux.com>
This PR adds headers support to ttrpc.
Signed-off-by: Maksym Pavlenko makpav@amazon.com