Sha256: b3c180a5e357337e15312591dd6f74bc47b90f00c020bc8f9cf30e9690b44a7b

Contents?: true

Size: 1.13 KB

Versions: 15

Compression:

Stored size: 1.13 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
logger.level = Logger::DEBUG

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

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

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)

logger.info "----- initialization started ----- "
client.wait_for_initialization
logger.info "----- initialization done ----- "

# 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.bool_variation(flagName, target, false)
  logger.info "Flag #{flagName} is set to:  #{result}"
  sleep 10
end

client.close


Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ff-ruby-server-sdk-1.4.6 example/getting_started/getting_started.rb
ff-ruby-server-sdk-1.4.5 example/getting_started/getting_started.rb
ff-ruby-server-sdk-1.4.4 example/getting_started/getting_started.rb
ff-ruby-server-sdk-1.4.3 example/getting_started/getting_started.rb
ff-ruby-server-sdk-1.4.2 example/getting_started/getting_started.rb
ff-ruby-server-sdk-1.4.1 example/getting_started/getting_started.rb
ff-ruby-server-sdk-1.4.0 example/getting_started/getting_started.rb
ff-ruby-server-sdk-1.3.2 example/getting_started/getting_started.rb
ff-ruby-server-sdk-1.3.1 example/getting_started/getting_started.rb
ff-ruby-server-sdk-1.2.1 example/getting_started/getting_started.rb
ff-ruby-server-sdk-1.2.0 example/getting_started/getting_started.rb
ff-ruby-server-sdk-1.1.4 example/getting_started/getting_started.rb
ff-ruby-server-sdk-1.1.3 example/getting_started/getting_started.rb
ff-ruby-server-sdk-1.1.2 example/getting_started/getting_started.rb
ff-ruby-server-sdk-1.1.1 example/getting_started/getting_started.rb