Class: Confium::Audit::Sink

Inherits:
Object
  • Object
show all
Defined in:
lib/confium/audit.rb

Overview

Base class for audit sinks. Subclasses override #write and optionally #close. The contract:

  • #write(record) — synchronously emit the record. Raise on failure; the exception propagates back through the caller.
  • #close — flush and release resources. Safe to call multiple times.

Direct Known Subclasses

FileSink, MemorySink, StderrSink

Instance Method Summary collapse

Instance Method Details

#call(record) ⇒ Object

Treat the Sink as a callable — delegates to #write. The Rust extension's audit module fires events by calling .call(record) on whatever is in Confium::Audit.sink, so this lets both Proc-based and Object-based sinks work through the same dispatch point.



47
48
49
# File 'lib/confium/audit.rb', line 47

def call(record)
  write(record)
end

#closeObject



51
52
53
# File 'lib/confium/audit.rb', line 51

def close
  # default no-op
end

#write(_record) ⇒ Object

Persist an audit record Hash. The Hash has these keys (all Strings):

  • "timestamp" — ISO8601 UTC, e.g. "2026-07-30T22:00:00Z"
  • "operation" — short slug like "composite_sign"
  • "actor" — optional String
  • "algorithm" — optional String
  • "payload_hash" — hex SHA-256 of the signed bytes
  • "result""success" or "failure"
  • "error" — optional String

Raises:

  • (NotImplementedError)


38
39
40
# File 'lib/confium/audit.rb', line 38

def write(_record)
  raise NotImplementedError, "#{self.class} must implement #write"
end