View Source OpenFeature.Provider behaviour (OpenFeature v0.1.1)
This module provides the behaviour that must be implemented by all providers. Also includes helper functions to be used with providers.
Summary
Callbacks
Initializes the provider with the domain and context, and sets the provider's state to :ready
.
Resolves the boolean value of a flag based on the key, default value, and context.
Resolves the map value of a flag based on the key, default value, and context.
Resolves the number value of a flag based on the key, default value, and context.
Resolves the string value of a flag based on the key, default value, and context.
Shuts down the provider and cleans up any resources.
Functions
Checks if two providers are equal based on their name, domain, and state.
Initializes the provider and emits the :ready
event if successful.
If an error occurs, emits the :error
event.
Resolves the value of a flag based on the key, default value, and context.
Shuts down the provider and catches any errors that may occur.
Validates if the provider implements the required functions.
Types
@type error() :: {:error, :flag_not_found} | {:error, :variant_not_found, binary() | nil} | {:error, :unexpected_error, Exception.t()}
@type success() :: {:ok, OpenFeature.ResolutionDetails.t()}
@type t() :: struct()
Callbacks
@callback initialize( provider :: t(), domain :: binary(), context :: OpenFeature.Types.context() ) :: {:ok, t()} | {:error, OpenFeature.Types.error_code()}
Initializes the provider with the domain and context, and sets the provider's state to :ready
.
resolve_boolean_value(provider, key, default, context)
View Source (since 0.1.0)@callback resolve_boolean_value( provider :: t(), key :: binary(), default :: boolean(), context :: OpenFeature.Types.context() ) :: result()
Resolves the boolean value of a flag based on the key, default value, and context.
@callback resolve_map_value( provider :: t(), key :: binary(), default :: map(), context :: OpenFeature.Types.context() ) :: result()
Resolves the map value of a flag based on the key, default value, and context.
resolve_number_value(provider, key, default, context)
View Source (since 0.1.0)@callback resolve_number_value( provider :: t(), key :: binary(), default :: number(), context :: OpenFeature.Types.context() ) :: result()
Resolves the number value of a flag based on the key, default value, and context.
resolve_string_value(provider, key, default, context)
View Source (since 0.1.0)@callback resolve_string_value( provider :: t(), key :: binary(), default :: binary(), context :: OpenFeature.Types.context() ) :: result()
Resolves the string value of a flag based on the key, default value, and context.
@callback shutdown(provider :: t()) :: :ok
Shuts down the provider and cleans up any resources.
Functions
Checks if two providers are equal based on their name, domain, and state.
@spec initialize( domain :: binary(), provider :: t(), context :: OpenFeature.Types.context() ) :: {:ok, t()} | {:error, any()}
Initializes the provider and emits the :ready
event if successful.
If an error occurs, emits the :error
event.
resolve_value(provider, atom, key, default, context)
View Source (since 0.1.0)@spec resolve_value( t(), OpenFeature.Types.flag_type(), OpenFeature.Types.flag_value(), OpenFeature.Types.flag_value(), OpenFeature.HookContext.t() ) :: result()
Resolves the value of a flag based on the key, default value, and context.
@spec shutdown(t()) :: :ok
Shuts down the provider and catches any errors that may occur.
Validates if the provider implements the required functions.