Sha256: 2771c6d266e69585138c6e3d30cab9abe44f7910c3f6eef69215eebe391292b4

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

require 'singleton'
require_relative "../../generated/lib/openapi_client"
require_relative "../common/closeable"
require_relative "inner_client"

class CfClient < Closeable
  include Singleton

  def init(api_key, config, connector = nil)
    # Only initialize if @client is nil to avoid reinitialization
    unless @client
      @config = config || ConfigBuilder.new.build
      @client = InnerClient.new(api_key, @config, connector)
      @config.logger.debug "Client initialized with API key: #{api_key}"
    end
    @client
  end


def wait_for_initialization(timeout_ms: nil)
    if @client != nil
      @client.wait_for_initialization(timeout: timeout_ms)
    end
  end

  def bool_variation(identifier, target, default_value)

    @client.bool_variation(identifier, target, default_value)
  end

  def string_variation(identifier, target, default_value)

    @client.string_variation(identifier, target, default_value)
  end

  def number_variation(identifier, target, default_value)

    @client.number_variation(identifier, target, default_value)
  end

  def json_variation(identifier, target, default_value)

    @client.json_variation(identifier, target, default_value)
  end

  def destroy

    close
  end

  def close

    if @client != nil

      @client.close
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ff-ruby-server-sdk-1.4.5 lib/ff/ruby/server/sdk/api/cf_client.rb
ff-ruby-server-sdk-1.4.4 lib/ff/ruby/server/sdk/api/cf_client.rb
ff-ruby-server-sdk-1.4.3 lib/ff/ruby/server/sdk/api/cf_client.rb
ff-ruby-server-sdk-1.4.2 lib/ff/ruby/server/sdk/api/cf_client.rb