Class: Textus::Infra::AuditSubscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/infra/audit_subscriber.rb

Overview

Writes an “event_error” audit row when a user hook raises during Hooks::Bus publish. Attached at Store boot.

Integration: uses Hooks::Bus#on_error callback (chosen over a synthetic :hook_error event because the bus already owns the rescue and the failure is a bus-internal concern, not a domain event subscribers should be able to filter by key glob).

NOTE (0.16 scope): lifecycle audit rows for verb: “put” / “delete” / “rename” are still written directly by Store::Writer and Application::Writes::Mv. Moving those into this subscriber requires event payloads to carry etag_before/etag_after across many write paths; that is properly a 0.18 port-extraction concern.

Instance Method Summary collapse

Constructor Details

#initialize(audit_log) ⇒ AuditSubscriber

Returns a new instance of AuditSubscriber.



19
20
21
# File 'lib/textus/infra/audit_subscriber.rb', line 19

def initialize(audit_log)
  @audit_log = audit_log
end

Instance Method Details

#attach(bus) ⇒ Object



23
24
25
26
27
28
# File 'lib/textus/infra/audit_subscriber.rb', line 23

def attach(bus)
  bus.on_error do |event:, hook:, key:, kwargs:, error:|
    record_error(event: event, hook: hook, key: key, kwargs: kwargs, error: error)
  end
  self
end