Class: Airbrake::RemoteSettings::SettingsData Private
- Inherits:
-
Object
- Object
- Airbrake::RemoteSettings::SettingsData
- Defined in:
- lib/airbrake-ruby/remote_settings/settings_data.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
SettingsData is a container, which wraps JSON payload returned by the remote settings API. It exposes the payload via convenient methods and also ensures that in case some data from the payload is missing, a default value would be returned instead.
Constant Summary collapse
- DEFAULT_INTERVAL =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Returns how frequently we should poll the config API.
600
- API_VER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Returns API version of the S3 API to poll.
'2020-06-18'.freeze
- CONFIG_ROUTE_PATTERN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Returns what path to poll.
"%<host>s/#{API_VER}/config/%<project_id>s/config.json".freeze
- SETTINGS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Returns the hash of all supported settings where the value is the name of the setting returned by the API.
{ errors: 'errors'.freeze, apm: 'apm'.freeze, }.freeze
Instance Method Summary collapse
-
#apm_host ⇒ String?
private
The host, which provides the API endpoint to which APM data should be sent.
-
#config_route(remote_config_host) ⇒ String
private
Where the config is stored on S3.
-
#error_host ⇒ String?
private
The host, which provides the API endpoint to which exceptions should be sent.
-
#error_notifications? ⇒ Boolean
private
Whether error notifications are enabled.
-
#initialize(project_id, data) ⇒ SettingsData
constructor
private
A new instance of SettingsData.
-
#interval ⇒ Integer
private
How frequently we should poll for the config.
-
#merge!(hash) ⇒ self
private
Merges the given
hash
with internal data. -
#performance_stats? ⇒ Boolean
private
Whether APM is enabled.
-
#to_h ⇒ Hash{String=>Object}
private
Raw representation of JSON payload.
Constructor Details
#initialize(project_id, data) ⇒ SettingsData
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of SettingsData.
36 37 38 39 |
# File 'lib/airbrake-ruby/remote_settings/settings_data.rb', line 36 def initialize(project_id, data) @project_id = project_id @data = data end |
Instance Method Details
#apm_host ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the host, which provides the API endpoint to which APM data should be sent.
96 97 98 99 100 |
# File 'lib/airbrake-ruby/remote_settings/settings_data.rb', line 96 def apm_host return unless (s = find_setting(SETTINGS[:apm])) s['endpoint'] end |
#config_route(remote_config_host) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns where the config is stored on S3.
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/airbrake-ruby/remote_settings/settings_data.rb', line 60 def config_route(remote_config_host) if @data['config_route'] && !@data['config_route'].empty? return "#{remote_config_host.chomp('/')}/#{@data['config_route']}" end format( CONFIG_ROUTE_PATTERN, host: remote_config_host.chomp('/'), project_id: @project_id, ) end |
#error_host ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the host, which provides the API endpoint to which exceptions should be sent.
88 89 90 91 92 |
# File 'lib/airbrake-ruby/remote_settings/settings_data.rb', line 88 def error_host return unless (s = find_setting(SETTINGS[:errors])) s['endpoint'] end |
#error_notifications? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether error notifications are enabled.
73 74 75 76 77 |
# File 'lib/airbrake-ruby/remote_settings/settings_data.rb', line 73 def error_notifications? return true unless (s = find_setting(SETTINGS[:errors])) s['enabled'] end |
#interval ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns how frequently we should poll for the config.
52 53 54 55 56 |
# File 'lib/airbrake-ruby/remote_settings/settings_data.rb', line 52 def interval return DEFAULT_INTERVAL if !@data.key?('poll_sec') || !@data['poll_sec'] @data['poll_sec'] > 0 ? @data['poll_sec'] : DEFAULT_INTERVAL end |
#merge!(hash) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Merges the given hash
with internal data.
45 46 47 48 49 |
# File 'lib/airbrake-ruby/remote_settings/settings_data.rb', line 45 def merge!(hash) @data.merge!(hash) self end |
#performance_stats? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether APM is enabled.
80 81 82 83 84 |
# File 'lib/airbrake-ruby/remote_settings/settings_data.rb', line 80 def performance_stats? return true unless (s = find_setting(SETTINGS[:apm])) s['enabled'] end |
#to_h ⇒ Hash{String=>Object}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns raw representation of JSON payload.
103 104 105 |
# File 'lib/airbrake-ruby/remote_settings/settings_data.rb', line 103 def to_h @data.dup end |