model

package
v1.0.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 0 Imported by: 1 module, 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 model holds the audit log's entity.

Index

Constants

View Source
const SystemActor = "system"

SystemActor is recorded for a change made with no caller behind it, such as the execution engine moving a process to its next status.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

Action is what was done to a record.

const (
	ActionCreate Action = "CREATE"
	ActionUpdate Action = "UPDATE"
	ActionDelete Action = "DELETE"
	// ActionUpsert is a write that inserts the record or, if it already exists,
	// updates it; the database does not say which happened.
	ActionUpsert Action = "UPSERT"
)

type Event

type Event struct {
	ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`

	// OccurredAt is when the change was made, in milliseconds since the epoch.
	OccurredAt int64 `` /* 168-byte string literal not displayed */

	// Actor is the principal's name — a users.user_id, "root", or "sa:<name>" — or
	// SystemActor.
	Actor string `gorm:"column:actor;type:varchar(255);not null;index:idx_audit_events_actor,priority:1" json:"actor"`

	Action Action `gorm:"column:action;type:varchar(10);not null" json:"action"`

	// EntityType is the table the record lives in, such as "processes", and EntityID its
	// primary key; a composite key is joined with ":". EntityID is empty when the
	// change addressed rows by a condition instead of by key.
	EntityType string `gorm:"column:entity_type;type:varchar(64);not null;index:idx_audit_events_entity,priority:1" json:"entityType"`
	EntityID   string `gorm:"column:entity_id;type:varchar(255);not null;default:'';index:idx_audit_events_entity,priority:2" json:"entityId"`

	// ChangedFields lists the columns an update named, comma-separated, when the write
	// named them. Empty for a create, a delete, and an update that saved the whole record.
	ChangedFields string `gorm:"column:changed_fields;type:varchar(1024);not null;default:''" json:"changedFields"`
}

Event is one change to one record: who made it, what was done and to what.

The table is append-only. Nothing in the server updates or deletes a row, and it deliberately has no foreign keys: an audit trail must outlive the users and records it describes, so Actor and EntityID are plain strings rather than references.

An event names the record, never its contents. Values are left out on purpose: rows carry token digests, SSH passwords and job secrets, and a log that copied them would be a second place to protect them.

func (Event) TableName

func (Event) TableName() string

TableName returns the table backing Event.

Jump to

Keyboard shortcuts

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