Sha256: 53c5941b9cc528252b6500f5c2d0699e13a51be3dec7da5733c95613505d6fdf

Contents?: true

Size: 1.01 KB

Versions: 20

Compression:

Stored size: 1.01 KB

Contents

require 'ff/ruby/server/sdk/api/config'
require 'ff/ruby/server/sdk/dto/target'
require 'ff/ruby/server/sdk/api/cf_client'
require 'ff/ruby/server/sdk/api/config_builder'

require "logger"
require "securerandom"

$stdout.sync = true
logger = Logger.new $stdout

# API Key
apiKey = ENV['FF_API_KEY'] || 'changeme'

# Flag Name
flagName = ENV['FF_FLAG_NAME'] || 'identifier_of_your_json_flag'

logger.info "Harness Ruby SDK Getting Started"

# Create a Feature Flag Client and wait for it to initialize
client = CfClient.instance

client.init(apiKey, ConfigBuilder.new.logger(logger).build)
client.wait_for_initialization

# Create a target (different targets can get different results based on rules.  This include a custom attribute 'location')
target = Target.new("RubySDK", identifier="rubysdk", attributes={"location": "emea"})

# Loop forever reporting the state of the flag
loop do
  result = client.json_variation(flagName, target, JSON.parse("{}"))
  logger.info "Flag variation:  #{result.to_json}"
  sleep 10
end

client.close


Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ff-ruby-server-sdk-1.4.6 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.4.5 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.4.4 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.4.3 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.4.2 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.4.1 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.4.0 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.3.2 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.3.1 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.2.1 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.2.0 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.1.4 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.1.3 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.1.2 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.1.1 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.1.0 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.0.6 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.0.5 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.0.4 example/json_variation_example/json_variation_example.rb
ff-ruby-server-sdk-1.0.3 example/json_variation_example/json_variation_example.rb