storage

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionLog

type ActionLog struct {
	Timestamp   time.Time
	AgentIDHash string
	Method      string
	Direction   string
	Success     bool
	LatencyMs   float64
	PayloadSize int
	AuthStatus  string
	ErrorCode   string
	IPAddress   string
}

ActionLog represents a single intercepted message log entry.

type DB

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

DB wraps a SQLite connection.

func Open

func Open(path string) (*DB, error)

Open opens (or creates) a SQLite database at path, enables WAL mode, and runs migrations.

func (*DB) Close

func (db *DB) Close() error

Close closes the underlying database connection.

func (*DB) Conn added in v0.2.0

func (db *DB) Conn() *sql.DB

Conn returns the underlying *sql.DB connection.

func (*DB) Insert

func (db *DB) Insert(log ActionLog) error

Insert stores a single ActionLog entry.

func (*DB) Purge

func (db *DB) Purge(retentionDays int) (int64, error)

Purge deletes log entries older than retentionDays days. Returns the number of rows deleted.

func (*DB) QueryLogs

func (db *DB) QueryLogs(opts QueryOptions) ([]ActionLog, error)

QueryLogs returns log entries matching opts, ordered newest-first.

func (*DB) SchemaVersion

func (db *DB) SchemaVersion() (int, error)

SchemaVersion returns the current schema version (for diagnostics).

type QueryOptions

type QueryOptions struct {
	Last      int
	AgentHash string
	Since     time.Duration
	Method    string
}

QueryOptions controls which log entries are returned by QueryLogs.

Jump to

Keyboard shortcuts

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