Interface QueryResponseSink
- All Known Implementing Classes:
SseQueryResponseSink
This is what keeps answering a query testable without a web stack: the endpoint adapts a response stream to this, and everything deciding what to write works against it rather than against the stream itself. Keeping an idle stream open is not among those decisions -- whether that takes writing anything at all, and what, is the transport's own business, so it lives on the implementation rather than here.
A sink is written to until it is terminated, which error(QueryDispatchFailure), complete(),
subscriptionComplete(String) or leaving(String) does. Nothing is written after that.
- Since:
- 5.4.0
- Author:
- Allard Buijze
-
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete()Ends the response stream, reporting that the query was answered in full.voiderror(QueryDispatchFailure error) Ends the response stream, reporting that the query failed.voidEnds the response stream, reporting that this member stops answering the subscription query because it is leaving the cluster.voidonUnavailable(Runnable listener) Registers alistenerto run once this sink can no longer be written to, for a reason other than the query having been answered — the member that asked stopped reading, or waited longer than it was given.voidresponse(QueryDispatchResponse response) Writes one response to the query being answered.voidsubscriptionComplete(String requestIdentifier) Reports that the subscription query being answered is over: there will never be another update to it.voidupdate(QueryDispatchResponse update) Writes one update to the subscription query being answered.
-
Method Details
-
response
Writes one response to the query being answered.- Parameters:
response- the response to write
-
update
Writes one update to the subscription query being answered.Distinct from
response(QueryDispatchResponse)because the subscriber acts on the two differently: a response belongs to the initial result, an update is a change after it.- Parameters:
update- the update to write
-
subscriptionComplete
Reports that the subscription query being answered is over: there will never be another update to it.Distinct from
leaving(String), which says only that this member stops answering, and from the stream merely ending, which fails the subscription. This says the subscription itself has run its course, and the subscriber stops waiting on every other member too.- Parameters:
requestIdentifier- the identifier of the subscription query that is over
-
leaving
Ends the response stream, reporting that this member stops answering the subscription query because it is leaving the cluster.Distinct from
subscriptionComplete(String), which ends the subscription for every member, and fromerror(QueryDispatchFailure), which fails it. This ends only this member's part: it has stopped emitting updates, so the subscriber carries on with the members that remain. Also distinct from the stream merely ending, which the subscriber cannot tell apart from a lost connection and so treats as a failure.- Parameters:
requestIdentifier- the identifier of the subscription query this member stops answering
-
error
Ends the response stream, reporting that the query failed.- Parameters:
error- the failure that ended the response stream
-
complete
void complete()Ends the response stream, reporting that the query was answered in full.