Support returning multiple streaming responses for a unary gRPC request - #134
Support returning multiple streaming responses for a unary gRPC request#134subnova wants to merge 1 commit into
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 |
| return new GrpcResponseDefinitionBuilder(Status.OK).fromJson(json); | ||
| } | ||
|
|
||
| public static GrpcResponseDefinitionBuilder messages( |
There was a problem hiding this comment.
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.
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-contributingor a project-specific channel like#wiremock-java