auditpg

package
v0.0.13-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package auditpg stores write and administrator audit records in PostgreSQL. Every other adapter records audit rows through it, inside its own business transaction; it is the one adapter that other adapters call directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RecordAdminMutation

func RecordAdminMutation(ctx context.Context, q *sqlc.Queries, tenant, action, resourceType, resourceID string) error

RecordAdminMutation records an administrator mutation in tenant, the Project that the administrator provenance names. Missing or malformed provenance fails with adminaudit.ErrInvalidSource.

func RecordDeploymentMutation

func RecordDeploymentMutation(ctx context.Context, q *sqlc.Queries, action, resourceType, resourceID string) error

RecordDeploymentMutation records a deployment-wide administrator mutation, which has no Project or tenant. Missing or malformed provenance fails with adminaudit.ErrInvalidSource.

func RecordWriteAudit

func RecordWriteAudit(ctx context.Context, q *sqlc.Queries, tenant string, action writeaudit.Action, resourceType writeaudit.ResourceType, resourceID, parentID string, created ...writeaudit.Resource) error

RecordWriteAudit records a public write in tenant and the resources the write genuinely created. Administrator provenance takes precedence. A write without provenance, such as internal lifecycle work, stays unattributed; malformed provenance fails closed with writeaudit.ErrInvalidSource. A request that already recorded its operation records nothing more.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store reads the audit records and applies write audit retention.

func New

func New(pool *pgunit.Pool) *Store

func (*Store) DeleteExpiredWriteOperations

func (s *Store) DeleteExpiredWriteOperations(ctx context.Context, olderThan time.Time, limit int) (int64, error)

DeleteExpiredWriteOperations deletes at most limit operations older than olderThan in one transaction. It never removes an operation referenced by a genuine creation anchor, even after the resource is deleted.

func (*Store) GetResourceOwners

func (s *Store) GetResourceOwners(ctx context.Context, tenantID, resourceType string, resourceIDs []string) ([]writeaudit.ResourceOwner, error)

GetResourceOwners returns each resource's recorded creating key in request order.

func (*Store) ListAdminAudit

func (s *Store) ListAdminAudit(ctx context.Context, filter adminaudit.Filter) (adminaudit.Page, error)

ListAdminAudit pages committed administrator mutations across the deployment, newest first, with the ID as the tie breaker.

func (*Store) ListWriteOperations

func (s *Store) ListWriteOperations(ctx context.Context, tenantID string, filter writeaudit.Filter) (writeaudit.Page, error)

ListWriteOperations pages a tenant's committed writes, newest first, with the ID as the tie breaker.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL