- 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 Summary
Modifier and TypeMethodDescriptiondefault voidafter(HookContext<T> ctx, FlagEvaluationDetails<T> details, Map<String, Object> hints) Runs after a flag is resolved.default Optional<EvaluationContext>Runs before flag is resolved.default voidRun when evaluation encounters an error.default voidfinallyAfter(HookContext<T> ctx, FlagEvaluationDetails<T> details, Map<String, Object> hints) Run after flag evaluation, including any error processing.default booleansupportsFlagValueType(FlagValueType flagValueType)
-
Method Details
-
before
Runs before flag is resolved.- Parameters:
ctx- Information about the particular flag evaluationhints- 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
Runs after a flag is resolved.- Parameters:
ctx- Information about the particular flag evaluationdetails- 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
Run when evaluation encounters an error. This will always run. Errors thrown will be swallowed.- Parameters:
ctx- Information about the particular flag evaluationerror- 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 evaluationhints- An immutable mapping of data for users to communicate to the hooks.
-
supportsFlagValueType
-