Class BackendInfoResolver<T extends BackendInfo>

  • All Implemented Interfaces:
    AutoCloseable

    public abstract class BackendInfoResolver<T extends BackendInfo>
    extends Object
    implements AutoCloseable
    Caching resolver which resolves a cookie to a leader ActorRef. This class needs to be specialized by the client. It is used by ClientActorBehavior for request dispatch. Results are cached until they are invalidated by either the client actor (when a message timeout is detected) and by the specific frontend (on explicit invalidation or when updated information becomes available).

    If the completion stage returned by this interface's methods fails with a RequestException, it will be forwarded to all outstanding requests towards the leader. If it fails with a TimeoutException, resolution process will be retried. If it fails with any other cause, it will we wrapped as a RuntimeRequestException wrapping that cause.

    Author:
    Robert Varga
    • Constructor Detail

      • BackendInfoResolver

        public BackendInfoResolver()
    • Method Detail

      • getBackendInfo

        public abstract @NonNull CompletionStage<? extends T> getBackendInfo​(@NonNull Long cookie)
        Request resolution of a particular backend identified by a cookie. This request can be satisfied from the cache.
        Parameters:
        cookie - Backend cookie
        Returns:
        A CompletionStage resulting in information about the backend
      • refreshBackendInfo

        public abstract @NonNull CompletionStage<? extends T> refreshBackendInfo​(@NonNull Long cookie,
                                                                                 @NonNull T staleInfo)
        Request re-resolution of a particular backend identified by a cookie, indicating a particular information as being stale. If the implementation's cache holds the stale information, it should be purged.
        Parameters:
        cookie - Backend cookie
        staleInfo - Stale backend information
        Returns:
        A CompletionStage resulting in information about the backend
      • notifyWhenBackendInfoIsStale

        public abstract @NonNull Registration notifyWhenBackendInfoIsStale​(Consumer<Long> callback)
        Registers a callback to be notified when BackendInfo that may have been previously obtained is now stale and should be refreshed.
        Parameters:
        callback - the callback that takes the backend cookie whose BackendInfo is now stale.
        Returns:
        a Registration
      • resolveCookieName

        public abstract @NonNull String resolveCookieName​(Long cookie)