Class: DatadogBackup::SLOs
- Defined in:
- lib/datadog_backup/slos.rb
Overview
SLO specific overrides for backup and restore.
Constant Summary
Constants inherited from Resources
Instance Method Summary collapse
- #all ⇒ Object
- #backup ⇒ Object
-
#body_with_2xx(response) ⇒ Object
Return the Faraday body from a response with a 2xx status code, otherwise raise an error.
- #get_by_id(id) ⇒ Object
-
#initialize(options) ⇒ SLOs
constructor
A new instance of SLOs.
Methods inherited from Resources
#create, #diff, #except, #get, #get_all, #get_and_write_file, #myclass, #restore, #update
Methods included from Options
#action, #backup_dir, #concurrency_limit, #diff_format, #disable_array_sort, #force_restore, #output_format, #resources
Methods included from LocalFilesystem
#all_file_ids, #all_file_ids_for_selected_resources, #all_files, #class_from_id, #dump, #file_type, #filename, #find_file_by_id, #load_from_file, #load_from_file_by_id, #mydir, #purge, #write_file
Constructor Details
#initialize(options) ⇒ SLOs
Returns a new instance of SLOs.
34 35 36 37 |
# File 'lib/datadog_backup/slos.rb', line 34 def initialize() super() @banlist = %w[modified_at url].freeze end |
Instance Method Details
#all ⇒ Object
6 7 8 |
# File 'lib/datadog_backup/slos.rb', line 6 def all get_all end |
#backup ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/datadog_backup/slos.rb', line 10 def backup LOGGER.info("Starting diffs on #{::DatadogBackup::ThreadPool::TPOOL.max_length} threads") futures = all.map do |slo| Concurrent::Promises.future_on(::DatadogBackup::ThreadPool::TPOOL, slo) do |board| id = board[id_keyname] get_and_write_file(id) end end watcher = ::DatadogBackup::ThreadPool.watcher watcher.join if watcher.status Concurrent::Promises.zip(*futures).value! end |
#body_with_2xx(response) ⇒ Object
Return the Faraday body from a response with a 2xx status code, otherwise raise an error
40 41 42 43 44 45 46 47 |
# File 'lib/datadog_backup/slos.rb', line 40 def body_with_2xx(response) unless response.status.to_s =~ /^2/ raise "#{caller_locations(1, 1)[0].label} failed with error #{response.status}" end response.body.fetch('data') end |
#get_by_id(id) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/datadog_backup/slos.rb', line 25 def get_by_id(id) begin slo = except(get(id)) rescue Faraday::ResourceNotFound => e slo = {} end except(slo) end |