Ruby Client for Prefab RateLimits, Config as a Service
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.ruby-version
Gemfile
Gemfile.lock
LICENSE.txt
README.md
Rakefile
VERSION
compile_protos.sh
prefab-cloud-ruby.gemspec

README.md

prefab-cloud-ruby

Ruby Client for Prefab RateLimits, FeatureFlags, Config as a Service: https://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 https://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: https://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

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2018 Jeff Dwyer. See LICENSE.txt for further details.