Documentation
¶
Overview ¶
Package audit records every change made to a persistent record.
It hooks the data layer rather than the HTTP layer, so a change is recorded whichever way it was made — an API call, the execution engine, a bootstrap step — and a request that changes nothing leaves nothing behind.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
Register makes gdb record an Event for every row its repositories create, update or delete. Call it once per connection, before the first write.
The Event is inserted on the same connection as the change, so inside a transaction the two commit or roll back together: no change goes unrecorded, and none is recorded that did not happen. The corollary is that a failure to write the Event fails the change itself. An audit trail that can silently lose entries is not one.
The caller is read from the context the repository was given. A repository call made without one — the execution engine's, for instance — is recorded as SystemActor.
Two things are not seen. Rows removed by a foreign key's ON DELETE CASCADE are removed by the database, so only the record that was deleted is recorded. And a write made through raw SQL bypasses the model entirely.
Types ¶
This section is empty.