Module: RoundhouseUi::Audit
- Defined in:
- lib/roundhouse_ui/audit.rb
Overview
An append-only audit trail of state-changing actions, kept in a capped Redis list. Answers "who purged that queue?" — the accountability Sidekiq Web lacks.
Constant Summary collapse
- KEY =
"roundhouse:audit"- MAX =
1_000
Class Method Summary collapse
Class Method Details
.recent(limit = 200) ⇒ Object
21 22 23 |
# File 'lib/roundhouse_ui/audit.rb', line 21 def recent(limit = 200) Sidekiq.redis { |conn| conn.call("LRANGE", KEY, 0, limit - 1) }.map { |raw| JSON.parse(raw) } end |
.record(actor:, action:, target:) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/roundhouse_ui/audit.rb', line 13 def record(actor:, action:, target:) entry = JSON.dump("actor" => actor.to_s, "action" => action.to_s, "target" => target.to_s, "at" => Time.now.to_f) Sidekiq.redis do |conn| conn.call("LPUSH", KEY, entry) conn.call("LTRIM", KEY, 0, MAX - 1) end end |