Class: Quonfig::Options

Inherits:
Object
  • Object
show all
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_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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Options

Returns a new instance of Options.



72
73
74
# File 'lib/quonfig/options.rb', line 72

def initialize(options = {})
  init(**options)
end

Instance Attribute Details

#api_urlsObject (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_intervalObject (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_urlsObject (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

#datadirObject (readonly)

Returns the value of attribute datadir.



8
9
10
# File 'lib/quonfig/options.rb', line 8

def datadir
  @datadir
end

#enable_pollingObject (readonly)

Returns the value of attribute enable_polling.



8
9
10
# File 'lib/quonfig/options.rb', line 8

def enable_polling
  @enable_polling
end

#enable_quonfig_user_contextObject (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_sseObject (readonly)

Returns the value of attribute enable_sse.



8
9
10
# File 'lib/quonfig/options.rb', line 8

def enable_sse
  @enable_sse
end

#environmentObject (readonly)

Returns the value of attribute environment.



8
9
10
# File 'lib/quonfig/options.rb', line 8

def environment
  @environment
end

#global_contextObject (readonly)

Returns the value of attribute global_context.



8
9
10
# File 'lib/quonfig/options.rb', line 8

def global_context
  @global_context
end

#initialization_timeout_secObject (readonly)

Returns the value of attribute initialization_timeout_sec.



8
9
10
# File 'lib/quonfig/options.rb', line 8

def initialization_timeout_sec
  @initialization_timeout_sec
end

#is_forkObject

Returns the value of attribute is_fork.



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

def is_fork
  @is_fork
end

#loggerObject (readonly)

Returns the value of attribute logger.



8
9
10
# File 'lib/quonfig/options.rb', line 8

def logger
  @logger
end

#logger_keyObject (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_failureObject (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_defaultObject (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

#poll_intervalObject (readonly)

Returns the value of attribute poll_interval.



8
9
10
# File 'lib/quonfig/options.rb', line 8

def poll_interval
  @poll_interval
end

#sdk_keyObject (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_urlsObject (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_destinationObject (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 `[“primary.quonfig-staging.com”, “secondary.quonfig-staging.com”]`.



47
48
49
50
51
52
# File 'lib/quonfig/options.rb', line 47

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'


66
67
68
69
70
# File 'lib/quonfig/options.rb', line 66

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.



55
56
57
# File 'lib/quonfig/options.rb', line 55

def self.derive_telemetry_url(domain)
  "https://telemetry.#{domain}"
end

.domainObject

Resolve the active domain. Reads QUONFIG_DOMAIN; falls back to DEFAULT_DOMAIN. Mirrors ‘cli/src/util/domain-urls.ts#getDomain`.



39
40
41
42
# File 'lib/quonfig/options.rb', line 39

def self.domain
  env = ENV.fetch('QUONFIG_DOMAIN', nil)
  env && !env.empty? ? env : DEFAULT_DOMAIN
end

Instance Method Details

#collect_max_evaluation_summariesObject



104
105
106
107
108
# File 'lib/quonfig/options.rb', line 104

def collect_max_evaluation_summaries
  return 0 unless telemetry_allowed?(@collect_evaluation_summaries)

  @collect_max_evaluation_summaries
end

#collect_max_example_contextsObject



98
99
100
101
102
# File 'lib/quonfig/options.rb', line 98

def collect_max_example_contexts
  return 0 unless telemetry_allowed?(@collect_example_contexts)

  @collect_max_example_contexts
end

#collect_max_pathsObject



86
87
88
89
90
# File 'lib/quonfig/options.rb', line 86

def collect_max_paths
  return 0 unless telemetry_allowed?(true)

  @collect_max_paths
end

#collect_max_shapesObject



92
93
94
95
96
# File 'lib/quonfig/options.rb', line 92

def collect_max_shapes
  return 0 unless telemetry_allowed?(@collect_shapes)

  @collect_max_shapes
end

#datadir?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/quonfig/options.rb', line 82

def datadir?
  !@datadir.nil?
end

#for_forkObject



114
115
116
117
118
# File 'lib/quonfig/options.rb', line 114

def for_fork
  clone = self.clone
  clone.is_fork = true
  clone
end

#local_only?Boolean

In datadir mode the SDK evaluates config from a local workspace and does not connect to the delivery service.

Returns:

  • (Boolean)


78
79
80
# File 'lib/quonfig/options.rb', line 78

def local_only?
  !@datadir.nil?
end

#sdk_key_idObject



110
111
112
# File 'lib/quonfig/options.rb', line 110

def sdk_key_id
  @sdk_key&.split('-')&.first
end