7
8
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
42
43
44
|
# File 'lib/textus/application/refresh/all.rb', line 7
def call(ctx, prefix: nil, zone: nil)
envelope_io = Textus::Application::Writes::EnvelopeIO.new(
file_store: ctx.file_store,
manifest: ctx.manifest,
schemas: ctx.schemas,
audit_log: ctx.audit_log,
ctx: ctx,
)
worker = Textus::Application::Refresh::Worker.new(ctx: ctx, envelope_io: envelope_io)
stale_rows = Textus::Application::Reads::Stale.new(ctx: ctx).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.message }
end
else
skipped << { "key" => key, "reason" => reason }
end
end
{
"protocol" => Textus::PROTOCOL,
"ok" => failed.empty?,
"refreshed" => refreshed,
"failed" => failed,
"skipped" => skipped,
}
end
|