Skip to content
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

Merged
merged 5 commits into from Jun 26, 2023

Conversation

schoren
Copy link
Collaborator

@schoren schoren commented Jun 23, 2023

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

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

Copy link
Contributor

@danielbdias danielbdias left a 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.


// 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func TestYamlstreamEncoding(t *testing.T) {
func TestYamlStreamEncoding(t *testing.T) {

@schoren schoren merged commit 7682428 into main Jun 26, 2023
25 checks passed
@schoren schoren deleted the resourcemanager-yaml-stream branch June 26, 2023 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants