Class: Textus::Write::RefreshAll
- Inherits:
-
Object
- Object
- Textus::Write::RefreshAll
- Defined in:
- lib/textus/write/refresh_all.rb
Instance Method Summary collapse
- #call(prefix: nil, zone: nil) ⇒ Object
-
#initialize(container:, call:) ⇒ RefreshAll
constructor
A new instance of RefreshAll.
Constructor Details
#initialize(container:, call:) ⇒ RefreshAll
Returns a new instance of RefreshAll.
4 5 6 7 |
# File 'lib/textus/write/refresh_all.rb', line 4 def initialize(container:, call:) @container = container @call = call end |
Instance Method Details
#call(prefix: nil, zone: nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/textus/write/refresh_all.rb', line 9 def call(prefix: nil, zone: nil) worker = Textus::Write::RefreshWorker.new( container: @container, call: @call, ) stale_rows = Textus::Read::Stale.new(container: @container, call: @call).call(prefix: prefix, zone: zone) refreshed = [] failed = [] skipped = [] stale_rows.each do |row| key = row["key"] || row[:key] reason = row["reason"] || row[:reason] if reason.to_s.match?(/ttl exceeded|never refreshed/) begin worker.run(key) refreshed << key rescue Textus::Error => e failed << { "key" => key, "error" => e. } end else skipped << { "key" => key, "reason" => reason } end end { "protocol" => Textus::PROTOCOL, "ok" => failed.empty?, "refreshed" => refreshed, "failed" => failed, "skipped" => skipped, } end |