You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ribbon transport clients use load balancer to execute a request for most of the use cases. When load balancer executes the request, it may involve with multiple servers and multiple retries on each server in order to fulfill the request. It will be nice to hook into this execution cycle with a listener to get notified of each execution event. This enables tracing on request level. Also, the listener mechanism allows loose coupling of logics that are not central to the execution of the network call like logging and statistics gathering.
Here is the high level interface design:
/** * A context object that is created at start of each load balancer execution * and contains certain meta data of the load balancer and mutable state data of * execution per listener per request. Each listener will get its own context * to work with. But it can also call {@link ExecutionContext#getGlobalContext()} to * get the shared context between all listeners. * */publicclassExecutionContext<T> {
publicTgetRequest();
publicObjectget(Stringname);
public <S> SgetClientProperty(IClientConfigKey<S> key);
publicvoidput(Stringname, Objectvalue) ;
/** * @return The IClientConfig object used to override the client's default configuration * for this specific execution. */publicIClientConfiggetRequestConfig();
/** * * @return The shared context for all listeners. */publicExecutionContext<T> getGlobalContext();
publicRetryHandlergetRetryHandler();
}
/** * Represents the state of execution for an instance of {@link com.netflix.loadbalancer.reactive.LoadBalancerObservableCommand} * and is passed to {@link ExecutionListener} */publicclassExecutionInfo {
publicServergetServer();
publicintgetNumberOfPastAttemptsOnServer();
publicintgetNumberOfPastServersAttempted();
}
/** * A listener to be invoked by load balancer at different stage of execution. * * @param <I> Input type used by {@link ExecutionContext} passed to * listener where it can call {@link ExecutionContext#getRequest()} to examine the * request object of the execution * @param <O> Output type from the load balancer execution, used by {@link #onExecutionSuccess(ExecutionContext, Object, com.netflix.loadbalancer.reactive.ExecutionInfo)} * API */publicinterfaceExecutionListener<I, O> {
/** * An exception to indicate that the listener wants to abort execution */classAbortExecutionExceptionextendsRuntimeException {
publicAbortExecutionException(Stringmessage) {
super(message);
}
publicAbortExecutionException(Stringmessage, Throwablecause) {
super(message, cause);
}
}
/** * Called when execution is about to start. * * @throws ExecutionListener.AbortExecutionException if the listener would * like to abort the execution */publicvoidonExecutionStart(ExecutionContext<I> context) throwsAbortExecutionException;
/** * Called when a server is chosen and the request is going to be executed on the server. * * @throws ExecutionListener.AbortExecutionException if the listener would * like to abort the execution */publicvoidonStartWithServer(ExecutionContext<I> context, ExecutionInfoinfo) throwsAbortExecutionException;
/** * Called when an exception is received from executing the request on a server. * * @param exception Exception received */publicvoidonExceptionWithServer(ExecutionContext<I> context, Throwableexception, ExecutionInfoinfo);
/** * Called when the request is executed successfully on the server * * @param response Object received from the execution */publicvoidonExecutionSuccess(ExecutionContext<I> context, Oresponse, ExecutionInfoinfo);
/** * Called when the request is considered failed after all retries. * * @param finalException Final exception received. This may be a wrapped exception indicating that all * retries have been exhausted. */publicvoidonExecutionFailed(ExecutionContext<I> context, ThrowablefinalException, ExecutionInfoinfo);
}
The text was updated successfully, but these errors were encountered:
Ribbon transport clients use load balancer to execute a request for most of the use cases. When load balancer executes the request, it may involve with multiple servers and multiple retries on each server in order to fulfill the request. It will be nice to hook into this execution cycle with a listener to get notified of each execution event. This enables tracing on request level. Also, the listener mechanism allows loose coupling of logics that are not central to the execution of the network call like logging and statistics gathering.
Here is the high level interface design:
The text was updated successfully, but these errors were encountered: