Package com.github.ambry.rest
Interface RestResponseHandler
-
public interface RestResponseHandler
Meant to be the component that handles and routes all outgoing responses. The responses are usually submitted by theRestRequestService
and sent out via theRestResponseChannel
with the RestResponseHandler forming a bridge between them to provide scaling capabilities and non-blocking behaviour. Implementations are expected to be thread-safe.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
handleResponse(RestRequest restRequest, RestResponseChannel restResponseChannel, ReadableStreamChannel response, java.lang.Exception exception)
Submit a response for a request along with a channel over which the response can be sent.void
shutdown()
Does shutdown tasks for the RestResponseHandler.void
start()
Does startup tasks for the RestResponseHandler.
-
-
-
Method Detail
-
start
void start() throws java.lang.InstantiationException
Does startup tasks for the RestResponseHandler. When the function returns, startup is FULLY complete.- Throws:
java.lang.InstantiationException
- if the RestResponseHandler is unable to start.
-
shutdown
void shutdown()
Does shutdown tasks for the RestResponseHandler. When the function returns, shutdown is FULLY complete. Any responses queued after shutdown is called might be dropped.
-
handleResponse
void handleResponse(RestRequest restRequest, RestResponseChannel restResponseChannel, ReadableStreamChannel response, java.lang.Exception exception) throws RestServiceException
Submit a response for a request along with a channel over which the response can be sent. If the response building was unsuccessful for any reason, the details should be included in theexception
. The bytes consumed from theresponse
are streamed out (unmodified) through therestResponseChannel
. Assumed that at least one ofresponse
orexception
is null. Depending on the implementation, it is possible that theresponse
is not immediately sent but en-queued to be sent at a later time.- Parameters:
restRequest
- theRestRequest
for which the response has been constructed.restResponseChannel
- theRestResponseChannel
to be used to send the response.response
- aReadableStreamChannel
that represents the response to therestRequest
.exception
- if the response could not be constructed, the reason for the failure.- Throws:
RestServiceException
- if there is any error while processing the response.
-
-