Class: Textus::Infra::AuditSubscriber
- Inherits:
-
Object
- Object
- Textus::Infra::AuditSubscriber
- Defined in:
- lib/textus/infra/audit_subscriber.rb
Overview
Writes an “event_error” audit row when a user hook raises during Hooks::EventBus publish. Attached at Store boot.
Integration: uses Hooks::EventBus#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).
Lifecycle audit rows for verb: “put” / “delete” / “rename” are written by Application::Envelope::Writer directly (it owns the audit-append-as-final-step invariant); this subscriber covers the hook-failure case the writer never sees.
Instance Method Summary collapse
- #attach(bus) ⇒ Object
-
#initialize(audit_log) ⇒ AuditSubscriber
constructor
A new instance of AuditSubscriber.
Constructor Details
#initialize(audit_log) ⇒ AuditSubscriber
Returns a new instance of AuditSubscriber.
18 19 20 |
# File 'lib/textus/infra/audit_subscriber.rb', line 18 def initialize(audit_log) @audit_log = audit_log end |
Instance Method Details
#attach(bus) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/textus/infra/audit_subscriber.rb', line 22 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 |