Class: CfClient

Inherits:
Closeable show all
Includes:
Singleton
Defined in:
lib/ff/ruby/server/sdk/api/cf_client.rb

Instance Method Summary collapse

Instance Method Details

#bool_variation(identifier, target, default_value) ⇒ Object



26
27
28
29
# File 'lib/ff/ruby/server/sdk/api/cf_client.rb', line 26

def bool_variation(identifier, target, default_value)

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

#closeObject



51
52
53
54
55
56
57
# File 'lib/ff/ruby/server/sdk/api/cf_client.rb', line 51

def close

  if @client != nil

    @client.close
  end
end

#destroyObject



46
47
48
49
# File 'lib/ff/ruby/server/sdk/api/cf_client.rb', line 46

def destroy

  close
end

#init(api_key, config, connector = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/ff/ruby/server/sdk/api/cf_client.rb', line 9

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

#json_variation(identifier, target, default_value) ⇒ Object



41
42
43
44
# File 'lib/ff/ruby/server/sdk/api/cf_client.rb', line 41

def json_variation(identifier, target, default_value)

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

#number_variation(identifier, target, default_value) ⇒ Object



36
37
38
39
# File 'lib/ff/ruby/server/sdk/api/cf_client.rb', line 36

def number_variation(identifier, target, default_value)

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

#string_variation(identifier, target, default_value) ⇒ Object



31
32
33
34
# File 'lib/ff/ruby/server/sdk/api/cf_client.rb', line 31

def string_variation(identifier, target, default_value)

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

#wait_for_initialization(timeout_ms: nil) ⇒ Object



20
21
22
23
24
# File 'lib/ff/ruby/server/sdk/api/cf_client.rb', line 20

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