Class: Textus::Write::FetchAll
- Inherits:
-
Object
- Object
- Textus::Write::FetchAll
- Extended by:
- Contract::DSL
- Defined in:
- lib/textus/write/fetch_all.rb
Instance Method Summary collapse
- #call(prefix: nil, zone: nil) ⇒ Object
-
#initialize(container:, call:) ⇒ FetchAll
constructor
A new instance of FetchAll.
Methods included from Contract::DSL
arg, around, cli, cli_stdin, contract, contract?, summary, surfaces, verb, view
Constructor Details
#initialize(container:, call:) ⇒ FetchAll
Returns a new instance of FetchAll.
13 14 15 16 |
# File 'lib/textus/write/fetch_all.rb', line 13 def initialize(container:, call:) @container = container @call = call end |
Instance Method Details
#call(prefix: nil, zone: nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/textus/write/fetch_all.rb', line 18 def call(prefix: nil, zone: nil) worker = Textus::Write::FetchWorker.new( container: @container, call: @call, ) stale_rows = Textus::Read::Stale.new(container: @container, call: @call).call(prefix: prefix, zone: zone) fetched = [] 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 fetched/) begin worker.run(key) fetched << 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?, "fetched" => fetched, "failed" => failed, "skipped" => skipped, } end |