Interface LoadBalancerLifecycle<RC,​RES,​T>


  • public interface LoadBalancerLifecycle<RC,​RES,​T>
    Allows to define actions that should be carried out before and after load-balancing.
    Author:
    Olga Maciaszek-Sharma
    • Method Detail

      • supports

        default boolean supports​(Class requestContextClass,
                                 Class responseClass,
                                 Class serverTypeClass)
        Allows to assess whether the lifecycle bean's callbacks should be executed. Some examples of possible implementations could comprise of verifying whether the classes passed in parameters are exactly or extend the classes that this lifecycle bean should process.
        Parameters:
        requestContextClass - The class of the Request context
        responseClass - The class of the CompletionContext clientResponse
        serverTypeClass - The type of Server that the LoadBalancer retrieves
        Returns:
        true if the lifecycle should be used to process given classes
      • onStart

        void onStart​(Request<RC> request)
        A callback method executed before load-balancing.
        Parameters:
        request - the Request that will be used by the LoadBalancer to select a service instance
      • onStartRequest

        void onStartRequest​(Request<RC> request,
                            Response<T> lbResponse)
        A callback method executed after a service instance has been selected, before executing the actual load-balanced request.
        Parameters:
        request - the Request that has been used by the LoadBalancer to select a service instance
        lbResponse - the Response returned by the LoadBalancer
      • onComplete

        void onComplete​(CompletionContext<RES,​T,​RC> completionContext)
        A callback method executed after load-balancing.
        Parameters:
        completionContext - the CompletionContext containing data relevant to the load-balancing and the response returned from the selected service instance