Sha256: b72d596bd3cd528c051c38113d39ed8c81ff1ae1856161964b28a7485e55b62e

Contents?: true

Size: 838 Bytes

Versions: 12

Compression:

Stored size: 838 Bytes

Contents

# Usage (from the repo root):
# env FLIPPER_CLOUD_TOKEN=<token> bundle exec ruby examples/cloud/threaded.rb

require_relative "./cloud_setup"
require 'bundler/setup'
require 'flipper/cloud'
require "active_support/notifications"
require "active_support/isolated_execution_state"

ActiveSupport::Notifications.subscribe(/poller\.flipper/) do |*args|
  p args: args
end

Flipper.configure do |config|
  config.default {
    Flipper::Cloud.new(local_adapter: config.adapter, instrumenter: ActiveSupport::Notifications)
  }
end

# Check every second to see if the feature is enabled
threads = []
10.times do
  threads << Thread.new do
    loop do
      sleep rand

      if Flipper[:stats].enabled?
        puts "#{Time.now.to_i} Enabled!"
      else
        puts "#{Time.now.to_i} Disabled!"
      end
    end
  end
end

threads.map(&:join)

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
flipper-1.0.0 examples/cloud/threaded.rb
flipper-1.0.0.pre examples/cloud/threaded.rb
flipper-cloud-0.28.3 examples/cloud/threaded.rb
flipper-cloud-0.28.2 examples/cloud/threaded.rb
flipper-cloud-0.28.1 examples/cloud/threaded.rb
flipper-cloud-0.28.0 examples/cloud/threaded.rb
flipper-cloud-0.27.1 examples/cloud/threaded.rb
flipper-cloud-0.27.0 examples/cloud/threaded.rb
flipper-cloud-0.26.2 examples/cloud/threaded.rb
flipper-cloud-0.26.1 examples/cloud/threaded.rb
flipper-cloud-0.26.0 examples/cloud/threaded.rb
flipper-cloud-0.26.0.rc2 examples/cloud/threaded.rb