Polyglot \ Internals
Request/Response Lifecycle
Learn about the internal request/response lifecycle in Polyglot.
Let’s follow the complete flow of a request through Polyglot:
Request Processing
- Application creates an
Inference
object - Application calls
create()
with parameters Inference
creates anInferenceRequest
.Inference
creates aPendingInference
object with the instances of request, driver and event dispatcher.Inference
returns aPendingInference
object to the application.
Response Processing
- Application accesses the
PendingInference
object content, e.g. viaresponse()
method. PendingInference
checks if HTTP request has been already executed.- If already sent, it returns the cached response.
PendingInference
dispatches theInferenceRequested
eventPendingInference
passes the request to the driver.- Driver uses request adapter to create HTTP request
- Request adapter uses request body formatter and message formatter.
- Driver sends the HTTP request and returns it to
PendingInference
. PendingInference
calls the driver to read and parse the response.- Driver uses a response adapter to extract content into appropriate fields of
InferenceResponse
object PendingInference
dispatches theInferenceResponseReceived
event- Result
InferenceResponse
object is returned to the application