prefab-cloud-ruby

Ruby Client for Prefab RateLimits, FeatureFlags, Config as a Service: www.prefab.cloud

client = Prefab::Client.new
@feature_flags = client.feature_flag_client

# Create a flag that is on for 10% of traffic, the entire beta group and user:1
@feature_flags.upsert(Prefab::FeatureFlag.new(feature: "MyFeature", pct: 0.1, whitelisted: ["betas", "user:1"]))

# Use Flags By Themselves
puts @feature_flags.feature_is_on? "MyFeature"  # returns yes 10 pct of the time

# A single user should get the same result each time
puts @feature_flags.feature_is_on? "MyFeature", "user:1123"

See full documentation www.prefab.cloud/documentation/installation

Supports

Important note about Forking and realtime updates

Many ruby web servers fork. GRPC does not like to be forked. You should manually start gRPC streaming in the on_worker_boot or after_fork hook of your server. See some details on GRPC and forking: github.com/grpc/grpc/issues/7951#issuecomment-335998583

#config/initializers/prefab.rb
$prefab = Prefab::Client.new(shared_cache: Rails.cache,
                             logdev: $stdout)
Rails.logger = $prefab.log
#puma.rb
on_worker_boot do
  $prefab.config_client.start_streaming
end

Contributing to prefab-cloud-ruby

Copyright © 2018 Jeff Dwyer. See LICENSE.txt for further details.