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, InMemoryConfigCache, LazyLoadingCachePolicy, ManualPollingCachePolicy, RolloutEvaluator, User

Constant Summary collapse

VERSION =
"1.0.1"
BASE_URL =
"https://cdn.configcat.com"
BASE_PATH =
"configuration-files/"
BASE_EXTENSION =
"/config_v2.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(api_key) ⇒ Object



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

def ConfigCat.create_client(api_key)
  #
  #   Create an instance of ConfigCatClient and setup Auto Poll mode with default options
  #
  #   :param api_key: ConfigCat ApiKey to access your configuration.
  #
  return create_client_with_auto_poll(api_key)
end

.create_client_with_auto_poll(api_key, poll_interval_seconds: 60, max_init_wait_time_seconds: 5, on_configuration_changed_callback: nil, config_cache_class: nil, base_url: 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
# File 'lib/configcat.rb', line 22

def ConfigCat.create_client_with_auto_poll(api_key, poll_interval_seconds: 60, max_init_wait_time_seconds: 5, on_configuration_changed_callback: nil, config_cache_class: nil, base_url: nil)
  #
  #   Create an instance of ConfigCatClient and setup Auto Poll mode with custom options
  #
  #   :param api_key: ConfigCat ApiKey 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
  #
  if api_key === nil
    raise ConfigCatClientException, "API 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(api_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)
end

.create_client_with_lazy_load(api_key, cache_time_to_live_seconds: 60, config_cache_class: nil, base_url: nil) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/configcat.rb', line 52

def ConfigCat.create_client_with_lazy_load(api_key, cache_time_to_live_seconds: 60, config_cache_class: nil, base_url: nil)
  #
  #   Create an instance of ConfigCatClient and setup Lazy Load mode with custom options
  #
  #   :param api_key: ConfigCat ApiKey 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
  #
  if api_key === nil
    raise ConfigCatClientException, "API Key is required."
  end
  if cache_time_to_live_seconds < 1
    cache_time_to_live_seconds = 1
  end
  return ConfigCatClient.new(api_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)
end

.create_client_with_manual_poll(api_key, config_cache_class: nil, base_url: nil) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/configcat.rb', line 77

def ConfigCat.create_client_with_manual_poll(api_key, config_cache_class: nil, base_url: nil)
  #
  #   Create an instance of ConfigCatClient and setup Manual Poll mode with custom options
  #
  #   :param api_key: ConfigCat ApiKey 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
  #
  if api_key === nil
    raise ConfigCatClientException, "API Key is required."
  end
  return ConfigCatClient.new(api_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)
end