Module: ConfigCat

Defined in:
lib/configcat.rb,
lib/configcat/user.rb,
lib/configcat/version.rb,
lib/configcat/interfaces.rb,
lib/configcat/configcache.rb,
lib/configcat/configfetcher.rb,
lib/configcat/configcatclient.rb,
lib/configcat/rolloutevaluator.rb,
lib/configcat/autopollingcachepolicy.rb,
lib/configcat/lazyloadingcachepolicy.rb,
lib/configcat/manualpollingcachepolicy.rb

Defined Under Namespace

Classes: AutoPollingCachePolicy, CacheControlConfigFetcher, CachePolicy, ConfigCache, ConfigCatClient, ConfigCatClientException, ConfigFetcher, FetchResponse, InMemoryConfigCache, LazyLoadingCachePolicy, ManualPollingCachePolicy, RolloutEvaluator, User

Constant Summary collapse

VERSION =
"3.0.0"
BASE_URL =
"https://cdn.configcat.com"
BASE_PATH =
"configuration-files/"
BASE_EXTENSION =
"/config_v4.json"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
end

Class Method Details

.create_client(sdk_key) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/configcat.rb', line 13

def ConfigCat.create_client(sdk_key)
  #
  #   Create an instance of ConfigCatClient and setup Auto Poll mode with default options
  #
  #   :param sdk_key: ConfigCat SDK Key to access your configuration.
  #
  return create_client_with_auto_poll(sdk_key)
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) ⇒ Object



22
23
24
25
26
27
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
# File 'lib/configcat.rb', line 22

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)
  #
  #   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
  #
  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)
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) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/configcat.rb', line 69

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)
  #
  #   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
  #
  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)
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) ⇒ Object



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
# File 'lib/configcat.rb', line 109

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)
  #
  #   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
  #
  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)
end