Sha256: 4c30f97b700ac4dc6dbd4178941bb22e9b07ad3f3f5819eb6604296083489448

Contents?: true

Size: 790 Bytes

Versions: 10

Compression:

Stored size: 790 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'

puts Process.pid

# Make a call in the parent process so we can detect forking.
Flipper.enabled?(:stats)

pids = 2.times.map do |n|
  fork {
    # Check every second to see if the feature is enabled
    threads = []
    2.times do
      threads << Thread.new do
        loop do
          sleep rand

          if Flipper[:stats].enabled?
            puts "#{Process.pid} #{Time.now.to_i} Enabled!"
          else
            puts "#{Process.pid} #{Time.now.to_i} Disabled!"
          end
        end
      end
    end
    threads.map(&:join)
  }
end

pids.each do |pid|
  Process.waitpid pid, 0
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
flipper-1.3.2 examples/cloud/forked.rb
flipper-1.3.1 examples/cloud/forked.rb
flipper-1.3.0 examples/cloud/forked.rb
flipper-1.3.0.pre examples/cloud/forked.rb
flipper-1.2.2 examples/cloud/forked.rb
flipper-1.2.1 examples/cloud/forked.rb
flipper-1.2.0 examples/cloud/forked.rb
flipper-1.1.2 examples/cloud/forked.rb
flipper-1.1.1 examples/cloud/forked.rb
flipper-1.1.0 examples/cloud/forked.rb