Class: Quonfig::Options
- Inherits:
-
Object
- Object
- Quonfig::Options
- Defined in:
- lib/quonfig/options.rb
Overview
Options passed to Quonfig::Client at construction time.
Defined Under Namespace
Modules: ON_INITIALIZATION_FAILURE, ON_NO_DEFAULT
Constant Summary collapse
- DEFAULT_FALLBACK_POLL_INTERVAL_MS =
Default fallback poll interval, in milliseconds. The SDK polls api-delivery at this cadence only when SSE is unavailable for >= 2x this value.
60_000- DEFAULT_INIT_TIMEOUT_MS =
Default initialization timeout, in milliseconds. The SDK waits up to this long for the initial config fetch before failing per :on_init_failure.
10_000- DEFAULT_CONFIG_FETCH_TIMEOUT_MS =
Default per-URL config-fetch timeout, in milliseconds (qfg-7h5d.1.9). Each leg in config_api_urls gets its own bounded attempt on the initial fetch AND the fallback poller, so a hung primary aborts fast (~3s) and leaves budget to reach the secondary inside init_timeout_ms instead of starving it until the global deadline. ~3s is short enough to fail over well inside a default 10s init budget, long enough to tolerate a slow-but-healthy upstream. Additive + a default that already fails over → backward compatible, not a breaking change.
3_000- DEFAULT_CONFIG_FETCH_HEDGE_DELAY_MS =
Default hedge delay, in milliseconds (qfg-7h5d.1.14). On the init/refresh config-fetch the SDK fires the PRIMARY leg first; if it has not settled within this delay (or errors fast) the SDK ALSO fires the secondary leg in PARALLEL without cancelling the primary. ~2s is below a realistic slow-but-alive primary's worst case yet far enough below the per-leg abort that a healthy sub-second primary is NEVER hedged — the secondary stays a cold standby and a healthy system adds zero secondary load. Standardized to 2000ms across all backend SDKs (qfg-7h5d.1.14). Tunable via
config_fetch_hedge_delay_ms. Additive + backward compatible. 2_000- DEFAULT_CONFIG_FETCH_HEDGE_ABORT_MS =
Default per-leg hedge hard-abort deadline, in milliseconds (qfg-7h5d.1.14). The hedged config-fetch path bounds each leg by this instead of #config_fetch_timeout_ms (which still governs the sequential FetchConfigs path). It MUST exceed the longest healable primary latency so a late-but- newer primary heals forward (rather than aborting), and MUST be < init_timeout_ms so the init-path heal leg is not clipped — the client logs a warning at construction if init_timeout_ms <= this value. ~6s sits between a ~3s slow-but-healthy upstream and the default 10s init budget. Tunable via
config_fetch_hedge_abort_ms. Additive + backward compatible. 6_000- DEFAULT_MAX_PATHS =
1_000- DEFAULT_MAX_KEYS =
100_000- DEFAULT_MAX_EXAMPLE_CONTEXTS =
100_000- DEFAULT_MAX_EVAL_SUMMARIES =
100_000- DEFAULT_DOMAIN =
Hardcoded fallback domain. Overridden by ENV.
'quonfig.com'- DEFAULT_API_URLS =
Hardcoded fallback API URLs (used only when no QUONFIG_DOMAIN is set and no explicit api_urls are provided). Mirrors derive_api_urls(DEFAULT_DOMAIN).
[ 'https://primary.quonfig.com', 'https://secondary.quonfig.com' ].freeze
Instance Attribute Summary collapse
-
#api_urls ⇒ Object
readonly
Returns the value of attribute api_urls.
-
#collect_sync_interval ⇒ Object
readonly
Returns the value of attribute collect_sync_interval.
-
#config_api_urls ⇒ Object
readonly
Returns the value of attribute config_api_urls.
-
#config_fetch_hedge_abort_ms ⇒ Object
readonly
Returns the value of attribute config_fetch_hedge_abort_ms.
-
#config_fetch_hedge_delay_ms ⇒ Object
readonly
Returns the value of attribute config_fetch_hedge_delay_ms.
-
#config_fetch_timeout_ms ⇒ Object
readonly
Returns the value of attribute config_fetch_timeout_ms.
-
#data_dir_auto_reload ⇒ Object
readonly
Returns the value of attribute data_dir_auto_reload.
-
#data_dir_auto_reload_debounce_ms ⇒ Object
readonly
Returns the value of attribute data_dir_auto_reload_debounce_ms.
-
#datadir ⇒ Object
readonly
Returns the value of attribute datadir.
-
#enable_quonfig_user_context ⇒ Object
readonly
Returns the value of attribute enable_quonfig_user_context.
-
#enable_sse ⇒ Object
readonly
Returns the value of attribute enable_sse.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#fallback_poll_enabled ⇒ Object
readonly
Returns the value of attribute fallback_poll_enabled.
-
#fallback_poll_interval_ms ⇒ Object
readonly
Returns the value of attribute fallback_poll_interval_ms.
-
#global_context ⇒ Object
readonly
Returns the value of attribute global_context.
-
#init_timeout_ms ⇒ Object
readonly
Returns the value of attribute init_timeout_ms.
-
#is_fork ⇒ Object
Returns the value of attribute is_fork.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#logger_key ⇒ Object
readonly
Returns the value of attribute logger_key.
-
#on_init_failure ⇒ Object
readonly
Returns the value of attribute on_init_failure.
-
#on_no_default ⇒ Object
readonly
Returns the value of attribute on_no_default.
-
#sdk_key ⇒ Object
readonly
Returns the value of attribute sdk_key.
-
#sse_api_urls ⇒ Object
readonly
Returns the value of attribute sse_api_urls.
-
#telemetry_destination ⇒ Object
readonly
Returns the value of attribute telemetry_destination.
Class Method Summary collapse
-
.derive_api_urls(domain) ⇒ Object
Derive default api_urls for a given domain.
-
.derive_stream_url(api_url) ⇒ Object
Derive the SSE stream URL for a given API URL by prepending
stream.to the hostname. -
.derive_telemetry_url(domain) ⇒ Object
Derive the telemetry URL for a given domain.
-
.domain ⇒ Object
Resolve the active domain.
Instance Method Summary collapse
- #collect_max_evaluation_summaries ⇒ Object
- #collect_max_example_contexts ⇒ Object
- #collect_max_paths ⇒ Object
- #collect_max_shapes ⇒ Object
- #datadir? ⇒ Boolean
-
#enable_polling ⇒ Object
Deprecated alias for #fallback_poll_enabled.
- #for_fork ⇒ Object
-
#initialization_timeout_sec ⇒ Object
Deprecated alias for #init_timeout_ms, in seconds.
-
#local_only? ⇒ Boolean
In datadir mode the SDK evaluates config from a local workspace and does not connect to the delivery service.
-
#poll_interval ⇒ Object
Deprecated alias for #fallback_poll_interval_ms, in seconds.
- #sdk_key_id ⇒ Object
Instance Attribute Details
#api_urls ⇒ Object (readonly)
Returns the value of attribute api_urls.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def api_urls @api_urls end |
#collect_sync_interval ⇒ Object (readonly)
Returns the value of attribute collect_sync_interval.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def collect_sync_interval @collect_sync_interval end |
#config_api_urls ⇒ Object (readonly)
Returns the value of attribute config_api_urls.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def config_api_urls @config_api_urls end |
#config_fetch_hedge_abort_ms ⇒ Object (readonly)
Returns the value of attribute config_fetch_hedge_abort_ms.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def config_fetch_hedge_abort_ms @config_fetch_hedge_abort_ms end |
#config_fetch_hedge_delay_ms ⇒ Object (readonly)
Returns the value of attribute config_fetch_hedge_delay_ms.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def config_fetch_hedge_delay_ms @config_fetch_hedge_delay_ms end |
#config_fetch_timeout_ms ⇒ Object (readonly)
Returns the value of attribute config_fetch_timeout_ms.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def config_fetch_timeout_ms @config_fetch_timeout_ms end |
#data_dir_auto_reload ⇒ Object (readonly)
Returns the value of attribute data_dir_auto_reload.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def data_dir_auto_reload @data_dir_auto_reload end |
#data_dir_auto_reload_debounce_ms ⇒ Object (readonly)
Returns the value of attribute data_dir_auto_reload_debounce_ms.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def data_dir_auto_reload_debounce_ms @data_dir_auto_reload_debounce_ms end |
#datadir ⇒ Object (readonly)
Returns the value of attribute datadir.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def datadir @datadir end |
#enable_quonfig_user_context ⇒ Object (readonly)
Returns the value of attribute enable_quonfig_user_context.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def enable_quonfig_user_context @enable_quonfig_user_context end |
#enable_sse ⇒ Object (readonly)
Returns the value of attribute enable_sse.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def enable_sse @enable_sse end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def environment @environment end |
#fallback_poll_enabled ⇒ Object (readonly)
Returns the value of attribute fallback_poll_enabled.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def fallback_poll_enabled @fallback_poll_enabled end |
#fallback_poll_interval_ms ⇒ Object (readonly)
Returns the value of attribute fallback_poll_interval_ms.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def fallback_poll_interval_ms @fallback_poll_interval_ms end |
#global_context ⇒ Object (readonly)
Returns the value of attribute global_context.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def global_context @global_context end |
#init_timeout_ms ⇒ Object (readonly)
Returns the value of attribute init_timeout_ms.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def init_timeout_ms @init_timeout_ms end |
#is_fork ⇒ Object
Returns the value of attribute is_fork.
12 13 14 |
# File 'lib/quonfig/options.rb', line 12 def is_fork @is_fork end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def logger @logger end |
#logger_key ⇒ Object (readonly)
Returns the value of attribute logger_key.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def logger_key @logger_key end |
#on_init_failure ⇒ Object (readonly)
Returns the value of attribute on_init_failure.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def on_init_failure @on_init_failure end |
#on_no_default ⇒ Object (readonly)
Returns the value of attribute on_no_default.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def on_no_default @on_no_default end |
#sdk_key ⇒ Object (readonly)
Returns the value of attribute sdk_key.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def sdk_key @sdk_key end |
#sse_api_urls ⇒ Object (readonly)
Returns the value of attribute sse_api_urls.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def sse_api_urls @sse_api_urls end |
#telemetry_destination ⇒ Object (readonly)
Returns the value of attribute telemetry_destination.
8 9 10 |
# File 'lib/quonfig/options.rb', line 8 def telemetry_destination @telemetry_destination end |
Class Method Details
.derive_api_urls(domain) ⇒ Object
Derive default api_urls for a given domain. e.g. for domain
quonfig-staging.com returns
["https://primary.quonfig-staging.com", "https://secondary.quonfig-staging.com"].
112 113 114 115 116 117 |
# File 'lib/quonfig/options.rb', line 112 def self.derive_api_urls(domain) [ "https://primary.#{domain}", "https://secondary.#{domain}" ] end |
.derive_stream_url(api_url) ⇒ Object
Derive the SSE stream URL for a given API URL by prepending stream. to
the hostname. Preserves scheme, port, and path.
derive_stream_url('https://primary.quonfig.com')
# => 'https://stream.primary.quonfig.com'
derive_stream_url('http://localhost:6550')
# => 'http://stream.localhost:6550'
131 132 133 134 135 |
# File 'lib/quonfig/options.rb', line 131 def self.derive_stream_url(api_url) uri = URI.parse(api_url) uri.host = "stream.#{uri.host}" if uri.host uri.to_s end |
.derive_telemetry_url(domain) ⇒ Object
Derive the telemetry URL for a given domain.
120 121 122 |
# File 'lib/quonfig/options.rb', line 120 def self.derive_telemetry_url(domain) "https://telemetry.#{domain}" end |
.domain ⇒ Object
Resolve the active domain. Reads QUONFIG_DOMAIN; falls back to
DEFAULT_DOMAIN. Mirrors cli/src/util/domain-urls.ts#getDomain.
104 105 106 107 |
# File 'lib/quonfig/options.rb', line 104 def self.domain env = ENV.fetch('QUONFIG_DOMAIN', nil) env && !env.empty? ? env : DEFAULT_DOMAIN end |
Instance Method Details
#collect_max_evaluation_summaries ⇒ Object
169 170 171 172 173 |
# File 'lib/quonfig/options.rb', line 169 def collect_max_evaluation_summaries return 0 unless telemetry_allowed?(@collect_evaluation_summaries) @collect_max_evaluation_summaries end |
#collect_max_example_contexts ⇒ Object
163 164 165 166 167 |
# File 'lib/quonfig/options.rb', line 163 def collect_max_example_contexts return 0 unless telemetry_allowed?(@collect_example_contexts) @collect_max_example_contexts end |
#collect_max_paths ⇒ Object
151 152 153 154 155 |
# File 'lib/quonfig/options.rb', line 151 def collect_max_paths return 0 unless telemetry_allowed?(true) @collect_max_paths end |
#collect_max_shapes ⇒ Object
157 158 159 160 161 |
# File 'lib/quonfig/options.rb', line 157 def collect_max_shapes return 0 unless telemetry_allowed?(@collect_shapes) @collect_max_shapes end |
#datadir? ⇒ Boolean
147 148 149 |
# File 'lib/quonfig/options.rb', line 147 def datadir? !@datadir.nil? end |
#enable_polling ⇒ Object
Deprecated alias for #fallback_poll_enabled. Will be removed in a future minor release.
56 57 58 |
# File 'lib/quonfig/options.rb', line 56 def enable_polling @fallback_poll_enabled end |
#for_fork ⇒ Object
179 180 181 182 183 |
# File 'lib/quonfig/options.rb', line 179 def for_fork clone = self.clone clone.is_fork = true clone end |
#initialization_timeout_sec ⇒ Object
Deprecated alias for #init_timeout_ms, in seconds. Reads back the timeout in the legacy unit so existing callers (e.g. internal code that passes this to Timeout.timeout) keep working. Will be removed in a future minor release.
72 73 74 75 |
# File 'lib/quonfig/options.rb', line 72 def initialization_timeout_sec ms = @init_timeout_ms.to_f / 1000.0 ms == ms.to_i ? ms.to_i : ms end |
#local_only? ⇒ Boolean
In datadir mode the SDK evaluates config from a local workspace and does not connect to the delivery service.
143 144 145 |
# File 'lib/quonfig/options.rb', line 143 def local_only? !@datadir.nil? end |
#poll_interval ⇒ Object
Deprecated alias for #fallback_poll_interval_ms, in seconds. Reads back the
interval in the legacy unit so existing callers (e.g. internal code that
sleeps on this value) keep working. Will be removed in a future minor
release.
64 65 66 |
# File 'lib/quonfig/options.rb', line 64 def poll_interval @fallback_poll_interval_ms / 1000.0 end |
#sdk_key_id ⇒ Object
175 176 177 |
# File 'lib/quonfig/options.rb', line 175 def sdk_key_id @sdk_key&.split('-')&.first end |