-
Notifications
You must be signed in to change notification settings - Fork 72
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
feat(server): add yaml stream encoding for resource manager #2817
Conversation
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.
Great PR! I added two small suggestions, but they are not important for now.
server/resourcemanager/encoding.go
Outdated
|
||
// getYamlstreamField returns the field in `target` with the name as the value of its yamlstream tag. | ||
// it returns an error if the field is not found or if the field is not of the specified kind. | ||
func getYamlstreamField(target interface{}, name string, kind reflect.Kind) (reflect.Value, error) { |
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.
func getYamlstreamField(target interface{}, name string, kind reflect.Kind) (reflect.Value, error) { | |
func getYamlStreamField(target interface{}, name string, kind reflect.Kind) (reflect.Value, error) { |
@@ -149,3 +149,89 @@ name: example | |||
}) | |||
|
|||
} | |||
|
|||
func TestYamlstreamEncoding(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.
func TestYamlstreamEncoding(t *testing.T) { | |
func TestYamlStreamEncoding(t *testing.T) { |
This PR adds support for multi-document YAML requests and responses in the
resourcemanager
package. Previously, it supported single-document YAML.The implementations uses a new encoder that can be used with the
text/yaml-stream
content-type/accept headers.With this change, we can handle requests and responses that contain multiple YAML documents separated by
---
lines.This means that a client can send a multi document request and it will work, but only if all the documents are of the same type (i.e. all transactions, or all tests, but not a mix of transactions and tests).
See it in action:
https://www.loom.com/share/dee1b1c35a544ee3b31bd00f1058ab1c
Checklist