Module: ToggleFleet
- Defined in:
- lib/togglefleet.rb,
lib/togglefleet/version.rb
Overview
ToggleFleet — cloud feature flags for Ruby.
Built from the ground up (Flipper's gate model as the reference, none of its code).
Design goals: evaluate flags LOCALLY so there is zero network on the hot path, refresh
the config in the background with conditional (ETag) requests, and fail safe.
ToggleFleet.configure { |c| c.sdk_key = ENV["TOGGLEFLEET_SDK_KEY"] }
ToggleFleet.register_group(:admins) { |user| user.admin? }
ToggleFleet.start
ToggleFleet.enabled?(:checkout_v2, actor: current_user)
Defined Under Namespace
Classes: Client, Configuration, Error
Constant Summary
collapse
- GATES =
The five gates, evaluated in order — first match wins (mirrors the server exactly).
%i[boolean actor group percentage_of_actors percentage_of_time].freeze
- VERSION =
"0.2.1"
Class Method Summary
collapse
Class Method Details
.all(**opts) ⇒ Object
279
|
# File 'lib/togglefleet.rb', line 279
def all(**opts) = client.all(**opts)
|
.client ⇒ Object
271
272
273
|
# File 'lib/togglefleet.rb', line 271
def client
@client ||= Client.new(config)
end
|
.config ⇒ Object
267
268
269
|
# File 'lib/togglefleet.rb', line 267
def config
@config ||= Configuration.new
end
|
256
257
258
259
260
261
262
263
264
265
|
# File 'lib/togglefleet.rb', line 256
def configure
@client&.stop
@config = Configuration.new
yield @config if block_given?
@client = Client.new(@config)
@config
end
|
.enabled?(flag, **opts) ⇒ Boolean
278
|
# File 'lib/togglefleet.rb', line 278
def enabled?(flag, **opts) = client.enabled?(flag, **opts)
|
.register_group(name, &block) ⇒ Object
275
|
# File 'lib/togglefleet.rb', line 275
def register_group(name, &block) = client.register_group(name, &block)
|
.reset! ⇒ Object
282
283
284
285
|
# File 'lib/togglefleet.rb', line 282
def reset!
@config = nil
@client = nil
end
|
.start ⇒ Object
276
|
# File 'lib/togglefleet.rb', line 276
def start = client.start
|
.sync ⇒ Object
277
|
# File 'lib/togglefleet.rb', line 277
def sync = client.sync
|