Class: Prefab::Options
- Inherits:
-
Object
- Object
- Prefab::Options
- 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 { |data| severity = data[:severity] datetime = data[:datetime] progname = data[:progname] path = data[:path] msg = data[:message] log_context = data[:log_context] progname = (progname.nil? || progname.empty?) ? path : "#{progname}: #{path}" formatted_log_context = log_context.sort.map do |k, v| "#{k}=#{v}" end.join(" ") "#{severity.ljust(5)} #{datetime}:#{' ' if progname}#{progname} #{msg}#{log_context.any? ? " " + formatted_log_context : ""}\n" }
- JSON_LOG_FORMATTER =
proc { |data| log_context = data.delete(:log_context) data.merge(log_context).compact.to_json << "\n" }
- COMPACT_LOG_FORMATTER =
proc { |data| severity = data[:severity] msg = data[:message] log_context = data[:log_context] log_context["path"] = data[:path] || "" formatted_log_context = log_context.sort.map do |k, v| "#{k}=#{v}" end.join(" ") "#{severity.ljust(5)} #{msg&.strip} #{formatted_log_context}\n" }
- DEFAULT_MAX_PATHS =
1_000
- DEFAULT_MAX_KEYS =
100_000
- DEFAULT_MAX_EXAMPLE_CONTEXTS =
100_000
- DEFAULT_MAX_EVAL_SUMMARIES =
100_000
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#collect_sync_interval ⇒ Object
readonly
Returns the value of attribute collect_sync_interval.
-
#datafile ⇒ Object
readonly
Returns the value of attribute datafile.
-
#disable_action_controller_logging ⇒ Object
readonly
Returns the value of attribute disable_action_controller_logging.
-
#initialization_timeout_sec ⇒ Object
readonly
Returns the value of attribute initialization_timeout_sec.
-
#is_fork ⇒ Object
Returns the value of attribute is_fork.
-
#log_formatter ⇒ Object
readonly
Returns the value of attribute log_formatter.
-
#log_prefix ⇒ Object
readonly
Returns the value of attribute log_prefix.
-
#logdev ⇒ Object
readonly
Returns the value of attribute logdev.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#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.
-
#prefab_api_url ⇒ Object
readonly
Returns the value of attribute prefab_api_url.
-
#prefab_config_classpath_dir ⇒ Object
readonly
Returns the value of attribute prefab_config_classpath_dir.
-
#prefab_config_override_dir ⇒ Object
readonly
Returns the value of attribute prefab_config_override_dir.
-
#prefab_envs ⇒ Object
readonly
Returns the value of attribute prefab_envs.
-
#use_local_cache ⇒ Object
readonly
Returns the value of attribute use_local_cache.
Instance Method Summary collapse
- #api_key_id ⇒ Object
- #collect_max_evaluation_summaries ⇒ Object
- #collect_max_example_contexts ⇒ Object
- #collect_max_paths ⇒ Object
- #collect_max_shapes ⇒ Object
- #datafile? ⇒ Boolean
- #for_fork ⇒ Object
-
#initialize(options = {}) ⇒ Options
constructor
A new instance of Options.
- #local_only? ⇒ Boolean
- #url_for_api_cdn ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Options
Returns a new instance of Options.
147 148 149 |
# File 'lib/prefab/options.rb', line 147 def initialize( = {}) init(**) end |
Instance Attribute Details
#api_key ⇒ Object (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_interval ⇒ Object (readonly)
Returns the value of attribute collect_sync_interval.
18 19 20 |
# File 'lib/prefab/options.rb', line 18 def collect_sync_interval @collect_sync_interval end |
#datafile ⇒ Object (readonly)
Returns the value of attribute datafile.
20 21 22 |
# File 'lib/prefab/options.rb', line 20 def datafile @datafile end |
#disable_action_controller_logging ⇒ Object (readonly)
Returns the value of attribute disable_action_controller_logging.
21 22 23 |
# File 'lib/prefab/options.rb', line 21 def disable_action_controller_logging @disable_action_controller_logging end |
#initialization_timeout_sec ⇒ Object (readonly)
Returns the value of attribute initialization_timeout_sec.
13 14 15 |
# File 'lib/prefab/options.rb', line 13 def initialization_timeout_sec @initialization_timeout_sec end |
#is_fork ⇒ Object
Returns the value of attribute is_fork.
22 23 24 |
# File 'lib/prefab/options.rb', line 22 def is_fork @is_fork end |
#log_formatter ⇒ Object (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_prefix ⇒ Object (readonly)
Returns the value of attribute log_prefix.
8 9 10 |
# File 'lib/prefab/options.rb', line 8 def log_prefix @log_prefix end |
#logdev ⇒ Object (readonly)
Returns the value of attribute logdev.
7 8 9 |
# File 'lib/prefab/options.rb', line 7 def logdev @logdev end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
10 11 12 |
# File 'lib/prefab/options.rb', line 10 def namespace @namespace end |
#on_init_failure ⇒ Object (readonly)
Returns the value of attribute on_init_failure.
14 15 16 |
# File 'lib/prefab/options.rb', line 14 def on_init_failure @on_init_failure end |
#on_no_default ⇒ Object (readonly)
Returns the value of attribute on_no_default.
12 13 14 |
# File 'lib/prefab/options.rb', line 12 def on_no_default @on_no_default end |
#prefab_api_url ⇒ Object (readonly)
Returns the value of attribute prefab_api_url.
11 12 13 |
# File 'lib/prefab/options.rb', line 11 def prefab_api_url @prefab_api_url end |
#prefab_config_classpath_dir ⇒ Object (readonly)
Returns the value of attribute prefab_config_classpath_dir.
16 17 18 |
# File 'lib/prefab/options.rb', line 16 def prefab_config_classpath_dir @prefab_config_classpath_dir end |
#prefab_config_override_dir ⇒ Object (readonly)
Returns the value of attribute prefab_config_override_dir.
15 16 17 |
# File 'lib/prefab/options.rb', line 15 def prefab_config_override_dir @prefab_config_override_dir end |
#prefab_envs ⇒ Object (readonly)
Returns the value of attribute prefab_envs.
17 18 19 |
# File 'lib/prefab/options.rb', line 17 def prefab_envs @prefab_envs end |
#use_local_cache ⇒ Object (readonly)
Returns the value of attribute use_local_cache.
19 20 21 |
# File 'lib/prefab/options.rb', line 19 def use_local_cache @use_local_cache end |
Instance Method Details
#api_key_id ⇒ Object
188 189 190 |
# File 'lib/prefab/options.rb', line 188 def api_key_id @api_key&.split("-")&.first end |
#collect_max_evaluation_summaries ⇒ Object
177 178 179 180 181 |
# File 'lib/prefab/options.rb', line 177 def collect_max_evaluation_summaries return 0 unless telemetry_allowed?(@collect_evaluation_summaries) @collect_max_evaluation_summaries end |
#collect_max_example_contexts ⇒ Object
171 172 173 174 175 |
# File 'lib/prefab/options.rb', line 171 def collect_max_example_contexts return 0 unless telemetry_allowed?(@collect_example_contexts) @collect_max_example_contexts end |
#collect_max_paths ⇒ Object
159 160 161 162 163 |
# File 'lib/prefab/options.rb', line 159 def collect_max_paths return 0 unless telemetry_allowed?(@collect_logger_counts) @collect_max_paths end |
#collect_max_shapes ⇒ Object
165 166 167 168 169 |
# File 'lib/prefab/options.rb', line 165 def collect_max_shapes return 0 unless telemetry_allowed?(@collect_shapes) @collect_max_shapes end |
#datafile? ⇒ Boolean
155 156 157 |
# File 'lib/prefab/options.rb', line 155 def datafile? !@datafile.nil? end |
#for_fork ⇒ Object
192 193 194 195 196 |
# File 'lib/prefab/options.rb', line 192 def for_fork clone = self.clone clone.is_fork = true clone end |
#local_only? ⇒ Boolean
151 152 153 |
# File 'lib/prefab/options.rb', line 151 def local_only? @prefab_datasources == DATASOURCES::LOCAL_ONLY end |
#url_for_api_cdn ⇒ Object
184 185 186 |
# File 'lib/prefab/options.rb', line 184 def url_for_api_cdn ENV['PREFAB_CDN_URL'] || "#{@prefab_api_url.gsub(/\./, '-')}.global.ssl.fastly.net" end |