Interface Hook<T>

Type Parameters:
T - The type of the flag being evaluated.
All Known Subinterfaces:
BooleanHook, DoubleHook, IntegerHook, StringHook
All Known Implementing Classes:
LoggingHook

public interface Hook<T>
An extension point which can run around flag resolution. They are intended to be used as a way to add custom logic to the lifecycle of flag evaluation.
  • Method Details

    • before

      default Optional<EvaluationContext> before(HookContext<T> ctx, Map<String,Object> hints)
      Runs before flag is resolved.
      Parameters:
      ctx - Information about the particular flag evaluation
      hints - An immutable mapping of data for users to communicate to the hooks.
      Returns:
      An optional EvaluationContext. If returned, it will be merged with the EvaluationContext instances from other hooks, the client and API.
    • after

      default void after(HookContext<T> ctx, FlagEvaluationDetails<T> details, Map<String,Object> hints)
      Runs after a flag is resolved.
      Parameters:
      ctx - Information about the particular flag evaluation
      details - Information about how the flag was resolved, including any resolved values.
      hints - An immutable mapping of data for users to communicate to the hooks.
    • error

      default void error(HookContext<T> ctx, Exception error, Map<String,Object> hints)
      Run when evaluation encounters an error. This will always run. Errors thrown will be swallowed.
      Parameters:
      ctx - Information about the particular flag evaluation
      error - The exception that was thrown.
      hints - An immutable mapping of data for users to communicate to the hooks.
    • finallyAfter

      default void finallyAfter(HookContext<T> ctx, FlagEvaluationDetails<T> details, Map<String,Object> hints)
      Run after flag evaluation, including any error processing. This will always run. Errors will be swallowed.
      Parameters:
      ctx - Information about the particular flag evaluation
      hints - An immutable mapping of data for users to communicate to the hooks.
    • supportsFlagValueType

      default boolean supportsFlagValueType(FlagValueType flagValueType)