Class: Prefab::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/prefab/options.rb

Overview

This class contains all the options that can be passed to the Prefab client.

Defined Under Namespace

Modules: DATASOURCES, ON_INITIALIZATION_FAILURE, ON_NO_DEFAULT

Constant Summary collapse

DEFAULT_LOG_FORMATTER =
proc { |severity, datetime, progname, msg|
  "#{severity.ljust(5)} #{datetime}:#{' ' if progname}#{progname} #{msg}\n"
}
JSON_LOG_FORMATTER =
proc { |severity, datetime, progname, msg, path|
  {
    type: severity,
    time: datetime,
    progname: progname,
    message: msg,
    path: path
  }.compact.to_json << "\n"
}
DEFAULT_MAX_PATHS =
1_000
DEFAULT_MAX_CONTEXT_KEYS =
100_000
DEFAULT_MAX_KEYS =
100_000
DEFAULT_MAX_EXAMPLE_CONTEXTS =
100_000
DEFAULT_MAX_EVAL_SUMMARIES =
100_000

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Options

Returns a new instance of Options.



114
115
116
# File 'lib/prefab/options.rb', line 114

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

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



6
7
8
# File 'lib/prefab/options.rb', line 6

def api_key
  @api_key
end

#collect_sync_intervalObject (readonly)

Returns the value of attribute collect_sync_interval.



20
21
22
# File 'lib/prefab/options.rb', line 20

def collect_sync_interval
  @collect_sync_interval
end

#initialization_timeout_secObject (readonly)

Returns the value of attribute initialization_timeout_sec.



15
16
17
# File 'lib/prefab/options.rb', line 15

def initialization_timeout_sec
  @initialization_timeout_sec
end

#log_formatterObject (readonly)

Returns the value of attribute log_formatter.



9
10
11
# File 'lib/prefab/options.rb', line 9

def log_formatter
  @log_formatter
end

#log_prefixObject (readonly)

Returns the value of attribute log_prefix.



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

def log_prefix
  @log_prefix
end

#logdevObject (readonly)

Returns the value of attribute logdev.



7
8
9
# File 'lib/prefab/options.rb', line 7

def logdev
  @logdev
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



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

def namespace
  @namespace
end

#on_init_failureObject (readonly)

Returns the value of attribute on_init_failure.



16
17
18
# File 'lib/prefab/options.rb', line 16

def on_init_failure
  @on_init_failure
end

#on_no_defaultObject (readonly)

Returns the value of attribute on_no_default.



14
15
16
# File 'lib/prefab/options.rb', line 14

def on_no_default
  @on_no_default
end

#prefab_api_urlObject (readonly)

Returns the value of attribute prefab_api_url.



13
14
15
# File 'lib/prefab/options.rb', line 13

def prefab_api_url
  @prefab_api_url
end

#prefab_config_classpath_dirObject (readonly)

Returns the value of attribute prefab_config_classpath_dir.



18
19
20
# File 'lib/prefab/options.rb', line 18

def prefab_config_classpath_dir
  @prefab_config_classpath_dir
end

#prefab_config_override_dirObject (readonly)

Returns the value of attribute prefab_config_override_dir.



17
18
19
# File 'lib/prefab/options.rb', line 17

def prefab_config_override_dir
  @prefab_config_override_dir
end

#prefab_envsObject (readonly)

Returns the value of attribute prefab_envs.



19
20
21
# File 'lib/prefab/options.rb', line 19

def prefab_envs
  @prefab_envs
end

#shared_cacheObject (readonly)

Returns the value of attribute shared_cache.



11
12
13
# File 'lib/prefab/options.rb', line 11

def shared_cache
  @shared_cache
end

#statsObject (readonly)

Returns the value of attribute stats.



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

def stats
  @stats
end

Instance Method Details

#collect_max_evaluation_summariesObject



146
147
148
149
150
# File 'lib/prefab/options.rb', line 146

def collect_max_evaluation_summaries
  return 0 unless telemetry_allowed?(@collect_evaluation_summaries)

  @collect_max_evaluation_summaries
end

#collect_max_example_contextsObject



140
141
142
143
144
# File 'lib/prefab/options.rb', line 140

def collect_max_example_contexts
  return 0 unless telemetry_allowed?(@collect_example_contexts)

  @collect_max_example_contexts
end

#collect_max_keysObject



134
135
136
137
138
# File 'lib/prefab/options.rb', line 134

def collect_max_keys
  return 0 unless telemetry_allowed?(@collect_keys)

  @collect_max_keys
end

#collect_max_pathsObject



122
123
124
125
126
# File 'lib/prefab/options.rb', line 122

def collect_max_paths
  return 0 unless telemetry_allowed?(@collect_logs)

  @collect_max_paths
end

#collect_max_shapesObject



128
129
130
131
132
# File 'lib/prefab/options.rb', line 128

def collect_max_shapes
  return 0 unless telemetry_allowed?(@collect_shapes)

  @collect_max_shapes
end

#local_only?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/prefab/options.rb', line 118

def local_only?
  @prefab_datasources == DATASOURCES::LOCAL_ONLY
end

#url_for_api_cdnObject



153
154
155
# File 'lib/prefab/options.rb', line 153

def url_for_api_cdn
  ENV['PREFAB_CDN_URL'] || "#{@prefab_api_url.gsub(/\./, '-')}.global.ssl.fastly.net"
end