Module: ConfigCat

Defined in:
lib/configcat.rb,
lib/configcat/user.rb,
lib/configcat/utils.rb,
lib/configcat/version.rb,
lib/configcat/constants.rb,
lib/configcat/interfaces.rb,
lib/configcat/configcache.rb,
lib/configcat/configentry.rb,
lib/configcat/pollingmode.rb,
lib/configcat/configfetcher.rb,
lib/configcat/configservice.rb,
lib/configcat/refreshresult.rb,
lib/configcat/datagovernance.rb,
lib/configcat/configcatclient.rb,
lib/configcat/configcatlogger.rb,
lib/configcat/configcatoptions.rb,
lib/configcat/rolloutevaluator.rb,
lib/configcat/evaluationdetails.rb,
lib/configcat/overridedatasource.rb,
lib/configcat/localfiledatasource.rb,
lib/configcat/localdictionarydatasource.rb

Defined Under Namespace

Classes: AutoPollingMode, ConfigCache, ConfigCatClient, ConfigCatClientException, ConfigCatLogger, ConfigCatOptions, ConfigEntry, ConfigFetcher, ConfigService, DataGovernance, EvaluationDetails, FetchResponse, FlagOverrides, Hooks, InMemoryConfigCache, KeyValue, LazyLoadingMode, LocalDictionaryDataSource, LocalDictionaryFlagOverrides, LocalFileDataSource, LocalFileFlagOverrides, ManualPollingMode, NullConfigCache, OverrideBehaviour, OverrideDataSource, PollingMode, RedirectMode, RefreshResult, RolloutEvaluator, Status, User, Utils

Constant Summary collapse

VERSION =
"6.0.0"
CONFIG_FILE_NAME =
"config_v5"
PREFERENCES =
"p"
BASE_URL =
"u"
REDIRECT =
"r"
FEATURE_FLAGS =
"f"
VALUE =
"v"
COMPARATOR =
"t"
COMPARISON_ATTRIBUTE =
"a"
COMPARISON_VALUE =
"c"
ROLLOUT_PERCENTAGE_ITEMS =
"p"
PERCENTAGE =
"p"
ROLLOUT_RULES =
"r"
VARIATION_ID =
"i"
BASE_URL_GLOBAL =
"https://cdn-global.configcat.com"
BASE_URL_EU_ONLY =
"https://cdn-eu.configcat.com"
BASE_PATH =
"configuration-files/"
BASE_EXTENSION =
"/" + CONFIG_FILE_NAME + ".json"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject

Returns the value of attribute logger.



11
12
13
# File 'lib/configcat.rb', line 11

def logger
  @logger
end

Class Method Details

.close_allObject

Closes all ConfigCatClient instances.



24
25
26
# File 'lib/configcat.rb', line 24

def ConfigCat.close_all
  ConfigCatClient.close_all
end

.create_client(sdk_key, data_governance: DataGovernance::GLOBAL) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/configcat.rb', line 28

def ConfigCat.create_client(sdk_key, data_governance: DataGovernance::GLOBAL)
  #
  #   Create an instance of ConfigCatClient and setup Auto Poll mode with default options
  #
  #   :param sdk_key: ConfigCat SDK Key to access your configuration.
  #   :param data_governance:
  #   Default: Global. Set this parameter to be in sync with the Data Governance preference on the Dashboard:
  #   https://app.configcat.com/organization/data-governance
  #   (Only Organization Admins have access)
  #
  return create_client_with_auto_poll(sdk_key, data_governance: data_governance)
end

.create_client_with_auto_poll(sdk_key, poll_interval_seconds: 60, max_init_wait_time_seconds: 5, on_configuration_changed_callback: nil, config_cache: nil, base_url: nil, proxy_address: nil, proxy_port: nil, proxy_user: nil, proxy_pass: nil, open_timeout_seconds: 10, read_timeout_seconds: 30, flag_overrides: nil, data_governance: DataGovernance::GLOBAL) ⇒ Object

Create an instance of ConfigCatClient and setup Auto Poll mode with custom options

:param sdk_key: ConfigCat SDK Key to access your configuration. :param poll_interval_seconds: The client’s poll interval in seconds. Default: 60 seconds. :param on_configuration_changed_callback: You can subscribe to configuration changes with this callback :param max_init_wait_time_seconds: maximum waiting time for first configuration fetch in polling mode. :param config_cache: If you want to use custom caching instead of the client’s default, You can provide an implementation of ConfigCache. :param base_url: You can set a base_url if you want to use a proxy server between your application and ConfigCat :param proxy_address: Proxy address :param proxy_port: Proxy port :param proxy_user: username for proxy authentication :param proxy_pass: password for proxy authentication :param open_timeout_seconds: The number of seconds to wait for the server to make the initial connection. Default: 10 seconds. :param read_timeout_seconds: The number of seconds to wait for the server to respond before giving up. Default: 30 seconds. :param flag_overrides: A FlagOverrides implementation used to override feature flags & settings. :param data_governance: Default: Global. Set this parameter to be in sync with the Data Governance preference on the Dashboard: app.configcat.com/organization/data-governance (Only Organization Admins have access)



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/configcat.rb', line 61

def ConfigCat.create_client_with_auto_poll(sdk_key,
                                           poll_interval_seconds: 60,
                                           max_init_wait_time_seconds: 5,
                                           on_configuration_changed_callback: nil,
                                           config_cache: nil,
                                           base_url: nil,
                                           proxy_address: nil,
                                           proxy_port: nil,
                                           proxy_user: nil,
                                           proxy_pass: nil,
                                           open_timeout_seconds: 10,
                                           read_timeout_seconds: 30,
                                           flag_overrides: nil,
                                           data_governance: DataGovernance::GLOBAL)
  options = ConfigCatOptions.new(
    base_url: base_url,
    polling_mode: PollingMode.auto_poll(poll_interval_seconds: poll_interval_seconds, max_init_wait_time_seconds: max_init_wait_time_seconds),
    config_cache: config_cache,
    proxy_address: proxy_address,
    proxy_port: proxy_port,
    proxy_user: proxy_user,
    proxy_pass: proxy_pass,
    open_timeout_seconds: open_timeout_seconds,
    read_timeout_seconds: read_timeout_seconds,
    flag_overrides: flag_overrides,
    data_governance: data_governance
  )
  client = ConfigCatClient.get(sdk_key, options)
  client.hooks.add_on_config_changed(on_configuration_changed_callback) if on_configuration_changed_callback
  client.log.warn('create_client_with_auto_poll is deprecated. Create the ConfigCat Client as a Singleton object with `configcatclient.get()` instead')
  return client
end

.create_client_with_lazy_load(sdk_key, cache_time_to_live_seconds: 60, config_cache: nil, base_url: nil, proxy_address: nil, proxy_port: nil, proxy_user: nil, proxy_pass: nil, open_timeout_seconds: 10, read_timeout_seconds: 30, flag_overrides: nil, data_governance: DataGovernance::GLOBAL) ⇒ Object

Create an instance of ConfigCatClient and setup Lazy Load mode with custom options

:param sdk_key: ConfigCat SDK Key to access your configuration. :param cache_time_to_live_seconds: The cache TTL. :param config_cache: If you want to use custom caching instead of the client’s default, You can provide an implementation of ConfigCache. :param base_url: You can set a base_url if you want to use a proxy server between your application and ConfigCat :param proxy_address: Proxy address :param proxy_port: Proxy port :param proxy_user: username for proxy authentication :param proxy_pass: password for proxy authentication :param open_timeout_seconds: The number of seconds to wait for the server to make the initial connection. Default: 10 seconds. :param read_timeout_seconds: The number of seconds to wait for the server to respond before giving up. Default: 30 seconds. :param flag_overrides: A FlagOverrides implementation used to override feature flags & settings. :param data_governance: Default: Global. Set this parameter to be in sync with the Data Governance preference on the Dashboard: app.configcat.com/organization/data-governance (Only Organization Admins have access)



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/configcat.rb', line 112

def ConfigCat.create_client_with_lazy_load(sdk_key,
                                           cache_time_to_live_seconds: 60,
                                           config_cache: nil,
                                           base_url: nil,
                                           proxy_address: nil,
                                           proxy_port: nil,
                                           proxy_user: nil,
                                           proxy_pass: nil,
                                           open_timeout_seconds: 10,
                                           read_timeout_seconds: 30,
                                           flag_overrides: nil,
                                           data_governance: DataGovernance::GLOBAL)
  options = ConfigCatOptions.new(
    base_url: base_url,
    polling_mode: PollingMode.lazy_load(cache_refresh_interval_seconds: cache_time_to_live_seconds),
    config_cache: config_cache,
    proxy_address: proxy_address,
    proxy_port: proxy_port,
    proxy_user: proxy_user,
    proxy_pass: proxy_pass,
    open_timeout_seconds: open_timeout_seconds,
    read_timeout_seconds: read_timeout_seconds,
    flag_overrides: flag_overrides,
    data_governance: data_governance
  )
  client = ConfigCatClient.get(sdk_key, options)
  client.log.warn('create_client_with_lazy_load is deprecated. Create the ConfigCat Client as a Singleton object with `configcatclient.get()` instead')
  return client
end

.create_client_with_manual_poll(sdk_key, config_cache: nil, base_url: nil, proxy_address: nil, proxy_port: nil, proxy_user: nil, proxy_pass: nil, open_timeout_seconds: 10, read_timeout_seconds: 30, flag_overrides: nil, data_governance: DataGovernance::GLOBAL) ⇒ Object

Create an instance of ConfigCatClient and setup Manual Poll mode with custom options

:param sdk_key: ConfigCat SDK Key to access your configuration. :param config_cache: If you want to use custom caching instead of the client’s default, You can provide an implementation of ConfigCache. :param base_url: You can set a base_url if you want to use a proxy server between your application and ConfigCat :param proxy_address: Proxy address :param proxy_port: Proxy port :param proxy_user: username for proxy authentication :param proxy_pass: password for proxy authentication :param open_timeout_seconds: The number of seconds to wait for the server to make the initial connection. Default: 10 seconds. :param read_timeout_seconds: The number of seconds to wait for the server to respond before giving up. Default: 30 seconds. :param flag_overrides: A FlagOverrides implementation used to override feature flags & settings. :param data_governance: Default: Global. Set this parameter to be in sync with the Data Governance preference on the Dashboard: app.configcat.com/organization/data-governance (Only Organization Admins have access)



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/configcat.rb', line 159

def ConfigCat.create_client_with_manual_poll(sdk_key,
                                             config_cache: nil,
                                             base_url: nil,
                                             proxy_address: nil,
                                             proxy_port: nil,
                                             proxy_user: nil,
                                             proxy_pass: nil,
                                             open_timeout_seconds: 10,
                                             read_timeout_seconds: 30,
                                             flag_overrides: nil,
                                             data_governance: DataGovernance::GLOBAL)
  options = ConfigCatOptions.new(
    base_url: base_url,
    polling_mode: PollingMode.manual_poll(),
    config_cache: config_cache,
    proxy_address: proxy_address,
    proxy_port: proxy_port,
    proxy_user: proxy_user,
    proxy_pass: proxy_pass,
    open_timeout_seconds: open_timeout_seconds,
    read_timeout_seconds: read_timeout_seconds,
    flag_overrides: flag_overrides,
    data_governance: data_governance
  )
  client = ConfigCatClient.get(sdk_key, options)
  client.log.warn('create_client_with_manual_poll is deprecated. Create the ConfigCat Client as a Singleton object with `configcatclient.get()` instead')
  return client
end

.get(sdk_key, options = nil) ⇒ Object

Creates a new or gets an already existing ConfigCatClient for the given sdk_key.

:param sdk_key [String] ConfigCat SDK Key to access your configuration. :param options [ConfigCatOptions] Configuration ConfigCatOptions for ConfigCatClient. :return [ConfigCatClient] the ConfigCatClient instance.



19
20
21
# File 'lib/configcat.rb', line 19

def ConfigCat.get(sdk_key, options = nil)
  return ConfigCatClient.get(sdk_key, options)
end