Module: ConfigCat

Defined in:
lib/configcat.rb,
lib/configcat/user.rb,
lib/configcat/version.rb,
lib/configcat/constants.rb,
lib/configcat/interfaces.rb,
lib/configcat/configcache.rb,
lib/configcat/configfetcher.rb,
lib/configcat/datagovernance.rb,
lib/configcat/configcatclient.rb,
lib/configcat/rolloutevaluator.rb,
lib/configcat/overridedatasource.rb,
lib/configcat/localfiledatasource.rb,
lib/configcat/autopollingcachepolicy.rb,
lib/configcat/lazyloadingcachepolicy.rb,
lib/configcat/manualpollingcachepolicy.rb,
lib/configcat/localdictionarydatasource.rb

Defined Under Namespace

Classes: AutoPollingCachePolicy, CacheControlConfigFetcher, CachePolicy, ConfigCache, ConfigCatClient, ConfigCatClientException, ConfigFetcher, DataGovernance, FetchResponse, InMemoryConfigCache, KeyValue, LazyLoadingCachePolicy, LocalDictionaryDataSource, LocalFileDataSource, ManualPollingCachePolicy, OverrideBehaviour, OverrideDataSource, RedirectMode, RolloutEvaluator, User

Constant Summary collapse

VERSION =
"5.0.1"
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.



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

def logger
  @logger
end

Class Method Details

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



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/configcat.rb', line 15

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_class: nil, base_url: nil, proxy_address: nil, proxy_port: nil, proxy_user: nil, proxy_pass: nil, open_timeout: 10, read_timeout: 30, flag_overrides: nil, data_governance: DataGovernance::GLOBAL) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
# File 'lib/configcat.rb', line 28

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_class: nil,
                                           base_url: nil,
                                           proxy_address: nil,
                                           proxy_port: nil,
                                           proxy_user: nil,
                                           proxy_pass: nil,
                                           open_timeout: 10,
                                           read_timeout: 30,
                                           flag_overrides: nil,
                                           data_governance: DataGovernance::GLOBAL)
  #
  #   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_class: If you want to use custom caching instead of the client's default InMemoryConfigCache,
  #   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: The number of seconds to wait for the server to make the initial connection. Default: 10 seconds.
  #   :param read_timeout: The number of seconds to wait for the server to respond before giving up. Default: 30 seconds.
  #   :param flag_overrides: An OverrideDataSource 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:
  #   https://app.configcat.com/organization/data-governance
  #   (Only Organization Admins have access)
  #
  if sdk_key === nil
    raise ConfigCatClientException, "SDK Key is required."
  end
  if poll_interval_seconds < 1
    poll_interval_seconds = 1
  end
  if max_init_wait_time_seconds < 0
    max_init_wait_time_seconds = 0
  end
  return ConfigCatClient.new(sdk_key,
                             poll_interval_seconds: poll_interval_seconds,
                             max_init_wait_time_seconds: max_init_wait_time_seconds,
                             on_configuration_changed_callback: on_configuration_changed_callback,
                             cache_time_to_live_seconds: 0,
                             config_cache_class: config_cache_class,
                             base_url: base_url,
                             proxy_address: proxy_address,
                             proxy_port: proxy_port,
                             proxy_user: proxy_user,
                             proxy_pass: proxy_pass,
                             open_timeout: open_timeout,
                             read_timeout: read_timeout,
                             flag_overrides: flag_overrides,
                             data_governance: data_governance)
end

.create_client_with_lazy_load(sdk_key, cache_time_to_live_seconds: 60, config_cache_class: nil, base_url: nil, proxy_address: nil, proxy_port: nil, proxy_user: nil, proxy_pass: nil, open_timeout: 10, read_timeout: 30, flag_overrides: nil, data_governance: DataGovernance::GLOBAL) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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
141
142
143
# File 'lib/configcat.rb', line 90

def ConfigCat.create_client_with_lazy_load(sdk_key,
                                           cache_time_to_live_seconds: 60,
                                           config_cache_class: nil,
                                           base_url: nil,
                                           proxy_address: nil,
                                           proxy_port: nil,
                                           proxy_user: nil,
                                           proxy_pass: nil,
                                           open_timeout: 10,
                                           read_timeout: 30,
                                           flag_overrides: nil,
                                           data_governance: DataGovernance::GLOBAL)
  #
  #   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_class: If you want to use custom caching instead of the client's default InMemoryConfigCache,
  #   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: The number of seconds to wait for the server to make the initial connection. Default: 10 seconds.
  #   :param read_timeout: The number of seconds to wait for the server to respond before giving up. Default: 30 seconds.
  #   :param flag_overrides: An OverrideDataSource 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:
  #   https://app.configcat.com/organization/data-governance
  #   (Only Organization Admins have access)
  #
  if sdk_key === nil
    raise ConfigCatClientException, "SDK Key is required."
  end
  if cache_time_to_live_seconds < 1
    cache_time_to_live_seconds = 1
  end
  return ConfigCatClient.new(sdk_key,
                             poll_interval_seconds: 0,
                             max_init_wait_time_seconds: 0,
                             on_configuration_changed_callback: nil,
                             cache_time_to_live_seconds: cache_time_to_live_seconds,
                             config_cache_class: config_cache_class,
                             base_url: base_url,
                             proxy_address: proxy_address,
                             proxy_port: proxy_port,
                             proxy_user: proxy_user,
                             proxy_pass: proxy_pass,
                             open_timeout: open_timeout,
                             read_timeout: read_timeout,
                             flag_overrides: flag_overrides,
                             data_governance: data_governance)
end

.create_client_with_manual_poll(sdk_key, config_cache_class: nil, base_url: nil, proxy_address: nil, proxy_port: nil, proxy_user: nil, proxy_pass: nil, open_timeout: 10, read_timeout: 30, flag_overrides: nil, data_governance: DataGovernance::GLOBAL) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
156
157
158
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
187
188
189
190
191
192
193
# File 'lib/configcat.rb', line 145

def ConfigCat.create_client_with_manual_poll(sdk_key,
                                             config_cache_class: nil,
                                             base_url: nil,
                                             proxy_address: nil,
                                             proxy_port: nil,
                                             proxy_user: nil,
                                             proxy_pass: nil,
                                             open_timeout: 10,
                                             read_timeout: 30,
                                             flag_overrides: nil,
                                             data_governance: DataGovernance::GLOBAL)
  #
  #   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_class: If you want to use custom caching instead of the client's default InMemoryConfigCache,
  #   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: The number of seconds to wait for the server to make the initial connection. Default: 10 seconds.
  #   :param read_timeout: The number of seconds to wait for the server to respond before giving up. Default: 30 seconds.
  #   :param flag_overrides: An OverrideDataSource 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:
  #   https://app.configcat.com/organization/data-governance
  #   (Only Organization Admins have access)
  #
  if sdk_key === nil
    raise ConfigCatClientException, "SDK Key is required."
  end
  return ConfigCatClient.new(sdk_key,
                             poll_interval_seconds: 0,
                             max_init_wait_time_seconds: 0,
                             on_configuration_changed_callback: nil,
                             cache_time_to_live_seconds: 0,
                             config_cache_class: config_cache_class,
                             base_url: base_url,
                             proxy_address: proxy_address,
                             proxy_port: proxy_port,
                             proxy_user: proxy_user,
                             proxy_pass: proxy_pass,
                             open_timeout: open_timeout,
                             read_timeout: read_timeout,
                             flag_overrides: flag_overrides,
                             data_governance: data_governance)
end