Flipper integration for RubyEventStore.
- Ensure that your Flipper has instrumentation enabled
- Enable RubyEventStore subscriber via
RubyEventStore::Flipper.enable(event_store_instance)
Example:
Flipper.configure do |config|
config.default do
# ... adapter configuration
# Enable instrumentation in Flipper
Flipper.new(adapter, instrumenter: ActiveSupport::Notifications)
end
end
# Enable RubyEventStore instrumentation for Flipper
RubyEventStore::Flipper.enable(Rails.configuration.event_store)
By default, stream name for toggle foobar
is FeatureToggle$foobar
. You can customize it via stream_pattern
argument:
RubyEventStore::Flipper.enable(
Rails.configuration.event_store,
stream_pattern: ->(feature_name) { "feature_toggle-#{feature_name}" },
)
Anything with the same API as ActiveSupport::Notifications
is supported.
RubyEventStore::Flipper.enable(Rails.configuration.event_store, instrumenter: AS::Notifications)
You can pass your own events to be used instead of default ones. Example:
Flipper.enable(event_store, custom_events: {
"ToggleAdded" => CustomModule::ToggleAdded,
"ToggleRemoved" => CustomModule::ToggleRemoved,
"ToggleGloballyEnabled" => CustomModule::ToggleGloballyEnabled,
"ToggleEnabledForActor" => CustomModule::ToggleEnabledForActor,
"ToggleEnabledForGroup" => CustomModule::ToggleEnabledForGroup,
"ToggleEnabledForPercentageOfActors" => CustomModule::ToggleEnabledForPercentageOfActors,
"ToggleEnabledForPercentageOfTime" => CustomModule::ToggleEnabledForPercentageOfTime,
"ToggleGloballyDisabled" => CustomModule::ToggleGloballyDisabled,
"ToggleDisabledForActor" => CustomModule::ToggleDisabledForActor,
"ToggleDisabledForGroup" => CustomModule::ToggleDisabledForGroup,
"ToggleDisabledForPercentageOfActors" => CustomModule::ToggleDisabledForPercentageOfActors,
"ToggleDisabledForPercentageOfTime" => CustomModule::ToggleDisabledForPercentageOfTime,
})