-
Notifications
You must be signed in to change notification settings - Fork 16
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 returning multiple streaming responses for a unary gRPC request #134
base: main
Are you sure you want to change the base?
Conversation
Thanks for contributing this. I'm going to hold off merging it though, as we plan to expand WireMock's core model for streaming/multi chunk responses and then utilise this for gRPC streaming. |
Look forward to seeing a more complete solution - but this would be a useful stop-gap for those of us who desperately need this feature. |
OK, that's fair enough, but let's find a way to enable this explicitly rather than it being the default behaviour when there's a streamed response defined. I suggest adding a response definition transformer that's enabled per-stub, that sets a response header indicating this behaviour be enabled. So e.g. the transformer would add |
@@ -50,6 +52,17 @@ public static GrpcResponseDefinitionBuilder message(MessageOrBuilder messageOrBu | |||
return new GrpcResponseDefinitionBuilder(Status.OK).fromJson(json); | |||
} | |||
|
|||
public static GrpcResponseDefinitionBuilder messages( |
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.
Suggest adding an overload taking a vararg so that it's not necessary to put List.of(...)
when calling.
List<MessageOrBuilder> messageOrBuilderList) { | ||
final String json = | ||
"[\n" | ||
+ messageOrBuilderList.stream() |
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.
Is serialising the whole list not possible?
Seems a bit messy to have to do string concat like this.
Support returning multiple streaming responses for a unary gRPC request.
Implementation
The JSON response is parsed into a JSON tree using Jackson's MappingIterator. Each JSON document is then mapped to a gRPC response as before and emitted using the gRPC stub response observer.
References
#55
Submitter checklist
#help-contributing
or a project-specific channel like#wiremock-java