abstract class OpenFeature::Hook

Overview

Hooks are a mechanism whereby application developers can add arbitrary behavior to flag evaluation. They operate similarly to middleware in many web frameworks.

Hooks add their logic at any of four specific stages of flag evaluation:

#before, immediately before flag evaluation #after, immediately after successful flag evaluation #error, immediately after an unsuccessful during flag evaluation #finally unconditionally after flag evaluation

Hooks can be configured to run globally (impacting all flag evaluations), per client, or per flag evaluation invocation. Some example use-cases for hook include adding additional data to the evaluation context, performing validation on the received flag value, providing data to telemetric tools, and logging errors.

Direct Known Subclasses

Defined in:

openfeature/hook.cr

Instance Method Summary

Instance Method Detail

abstract def after(ctx : HookContext, hints : Metadata, flag_details : FlagEvaluationDetails) #

immediately after successful flag evaluation


[View source]
abstract def before(ctx : HookContext, hints : Metadata) : EvaluationContext | Nil #

immediately before flag evaluation


[View source]
abstract def error(ctx : HookContext, hints : Metadata, ex : Exception) #

immediately after an unsuccessful during flag evaluation


[View source]
abstract def finally(ctx : HookContext, hints : Metadata) #

unconditionally after flag evaluation


[View source]