API documentation

Generated from Go source doc comments — module github.com/fraser-isbester/tusk.

github.com/fraser-isbester/tusk/cmd/tusk

package main

No package overview.

github.com/fraser-isbester/tusk/internal/config

package config

No package overview.

type Config

type Config struct {
	Profiles	map[string]Profile	`yaml:"profiles"`
	DefaultProfile	string			`yaml:"default_profile"`
}

Config holds all configuration profiles for Tusk.

func Load

func Load() (*Config, error)

Load reads the Tusk configuration. It tries, in order:

  1. ~/.config/tusk/config.yaml
  2. DATABASE_URL environment variable
  3. PG* environment variables (PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE)
  4. Sensible defaults (localhost:5432, user postgres)

func (Config) ResolveProfile

func (c *Config) ResolveProfile(name string) (Profile, error)

ResolveProfile returns the named profile from the config. If name is empty, the default profile is used. If no profiles are configured, a profile is built from environment variables and defaults.

type Profile

type Profile struct {
	Host		string			`yaml:"host"`
	Port		int			`yaml:"port"`
	User		string			`yaml:"user"`
	Password	string			`yaml:"password"`
	Database	string			`yaml:"database"`
	SSLMode		string			`yaml:"sslmode"`
	URL		string			`yaml:"url"`
	Readonly	bool			`yaml:"readonly"`
	Color		string			`yaml:"color"`
	RefreshInterval	time.Duration		`yaml:"refresh_interval"`
	Rules		[]rules.RuleConfig	`yaml:"rules"`
}

Profile represents a single PostgreSQL connection profile.

func (Profile) ConnectionString

func (p Profile) ConnectionString() string

ConnectionString returns a PostgreSQL connection string for this profile. If URL is set directly, it is returned as-is. Otherwise, the string is assembled from the individual fields.

github.com/fraser-isbester/tusk/internal/db

package db

No package overview.

type ColumnInfo

type ColumnInfo struct {
	Name		string
	DataType	string
	Nullable	bool
	Default		string
	IsPrimary	bool
}

ColumnInfo describes a single column in a table.

type ConnectionGroup

type ConnectionGroup struct {
	User	string
	App	string
	State	string
	Count	int
}

ConnectionGroup is an aggregated view of connections sharing the same user, application, and state.

type DB

type DB struct {

}// contains filtered or unexported fields

DB wraps a pgxpool.Pool and provides query helpers for Tusk.

func New

func New(connString string) (*DB, error)

New creates a new connection pool to the PostgreSQL instance identified by connString. The pool is limited to 3 connections and each connection sets a 2-second statement_timeout on creation.

func (DB) CancelQuery

func (d *DB) CancelQuery(ctx context.Context, pid int) error

CancelQuery sends pg_cancel_backend for the given PID.

func (DB) Close

func (d *DB) Close()

Close releases all connections in the pool.

func (DB) GetActiveQueries

func (d *DB) GetActiveQueries(ctx context.Context) ([]Query, error)

GetActiveQueries returns all active backends from pg_stat_activity, excluding the caller's own connection.

func (DB) GetConnections

func (d *DB) GetConnections(ctx context.Context) ([]ConnectionGroup, error)

GetConnections returns connections grouped by user, application, and state.

func (DB) GetDatabaseStats

func (d *DB) GetDatabaseStats(ctx context.Context) (*DatabaseStats, error)

GetDatabaseStats returns activity counters for the current database.

func (DB) GetDatabases

func (d *DB) GetDatabases(ctx context.Context) ([]DatabaseInfo, error)

GetDatabases returns all non-template databases with their sizes.

func (DB) GetIndexes

func (d *DB) GetIndexes(ctx context.Context) ([]IndexInfo, error)

GetIndexes returns per-index statistics from pg_stat_user_indexes.

func (DB) GetLocks

func (d *DB) GetLocks(ctx context.Context) ([]Lock, error)

GetLocks returns information about blocked locks and their blockers.

func (DB) GetRoles

func (d *DB) GetRoles(ctx context.Context) ([]RoleInfo, error)

GetRoles returns all roles and their key privileges.

func (DB) GetServerInfo

func (d *DB) GetServerInfo(ctx context.Context) (*ServerInfo, error)

GetServerInfo returns the server version, uptime, and max_connections.

func (DB) GetSlowQueries

func (d *DB) GetSlowQueries(ctx context.Context) ([]SlowQuery, error)

GetSlowQueries returns the top 50 queries by total execution time from pg_stat_statements. Returns an empty slice if the extension is not installed.

func (DB) GetTableDetail

func (d *DB) GetTableDetail(ctx context.Context, schema, name string) (*TableDetail, error)

GetTableDetail returns detailed information about a single table including columns, indexes, and statistics.

func (DB) GetTables

func (d *DB) GetTables(ctx context.Context) ([]TableInfo, error)

GetTables returns per-table statistics from pg_stat_user_tables.

func (DB) GetTransactions

func (d *DB) GetTransactions(ctx context.Context) ([]Transaction, error)

GetTransactions returns all active transactions from pg_stat_activity.

func (DB) Pool

func (d *DB) Pool() *pgxpool.Pool

Pool returns the underlying pgxpool.Pool.

func (DB) TerminateBackend

func (d *DB) TerminateBackend(ctx context.Context, pid int) error

TerminateBackend sends pg_terminate_backend for the given PID.

type DatabaseInfo

type DatabaseInfo struct {
	Name	string
	Size	int64
	Owner	string
}

DatabaseInfo describes a single non-template database.

type DatabaseStats

type DatabaseStats struct {
	XactCommit	int64
	XactRollback	int64
	BlksHit		int64
	BlksRead	int64
	CacheHitRatio	float64
}

DatabaseStats holds activity counters for a single database.

type IndexInfo

type IndexInfo struct {
	Schema		string
	Table		string
	IndexName	string
	Scans		int64
	TupRead		int64
	TupFetch	int64
	Size		int64
}

IndexInfo holds per-index statistics from pg_stat_user_indexes.

type Lock

type Lock struct {
	BlockedPID	int
	BlockingPID	int
	BlockedUser	string
	BlockingUser	string
	BlockedApp	string
	BlockingApp	string
	LockType	string
	Mode		string
	WaitDuration	time.Duration
	BlockedQuery	string
	BlockingQuery	string
}

Lock describes a blocked lock and the backend blocking it.

type Query

type Query struct {
	ResourceBase
	Duration	time.Duration
	QueryStart	time.Time
	WaitEventType	string
	WaitEvent	string
	QueryText	string
	Comment		SQLComment
	BlockedBy	int
	QueryID		int64
}// when this query started executing

Query represents a single in-flight backend from pg_stat_activity.

type QueryHistory

type QueryHistory struct {

}// contains filtered or unexported fields

QueryHistory tracks the sequence of queries observed per backend session. Each session keeps a ring buffer of the last N distinct queries.

func NewQueryHistory

func NewQueryHistory(maxPerSession int) *QueryHistory

NewQueryHistory creates a new query history tracker.

func (QueryHistory) Cleanup

func (h *QueryHistory) Cleanup(activeKeys map[sessionKey]bool)

Cleanup removes entries for sessions that are no longer active.

func (QueryHistory) Get

func (h *QueryHistory) Get(pid int, backendStart time.Time) []QueryHistoryEntry

Get returns the query history for a backend session (oldest first).

func (QueryHistory) Record

func (h *QueryHistory) Record(pid int, backendStart time.Time, query, state string)

Record adds a query observation for a backend session. Only records if the query text differs from the last recorded entry.

func (QueryHistory) RecordAll

func (h *QueryHistory) RecordAll(queries []Query)

RecordAll records observations from a slice of active queries.

func (QueryHistory) RecordTransactions

func (h *QueryHistory) RecordTransactions(txns []Transaction)

RecordTransactions records observations from a slice of transactions. Uses XactStart as the session key so each transaction gets its own history.

type QueryHistoryEntry

type QueryHistoryEntry struct {
	Query		string
	State		string
	Timestamp	time.Time
}

QueryHistoryEntry records a query observed for a backend at a point in time.

type ResourceBase

type ResourceBase struct {
	PID		int
	User		string
	App		string
	Database	string
	ClientAddr	string
	State		string
	BackendStart	time.Time
}// when this backend process started — unique with PID

ResourceBase contains fields shared across all pg_stat_activity-derived resources.

type RoleInfo

type RoleInfo struct {
	Name		string
	IsSuperuser	bool
	CanCreateRole	bool
	CanCreateDB	bool
	CanLogin	bool
	ConnLimit	int
}

RoleInfo describes a PostgreSQL role and its key privileges.

type SQLComment

type SQLComment struct {
	App		string
	Route		string
	Controller	string
	Action		string
	Framework	string
}

SQLComment holds metadata extracted from a SQLcommentor-style comment appended to a query string.

func ParseSQLComment

func ParseSQLComment(query string) SQLComment

ParseSQLComment extracts SQLcommentor key-value pairs from the trailing block comment of a SQL query. Returns an empty SQLComment if no comment is found.

type ServerInfo

type ServerInfo struct {
	Version		string
	Uptime		time.Duration
	MaxConnections	int
}

ServerInfo holds high-level PostgreSQL server metadata.

type SlowQuery

type SlowQuery struct {
	QueryID		int64
	Query		string
	Calls		int64
	TotalTime	float64
	MeanTime	float64
	Rows		int64
	HitRatio	float64
}

SlowQuery holds a row from pg_stat_statements ordered by total execution time.

type TableDetail

type TableDetail struct {
	Schema		string
	Name		string
	TotalSize	int64
	LiveTuples	int64
	DeadTuples	int64
	SeqScan		int64
	IdxScan		int64
	LastVacuum	*time.Time
	LastAutoVacuum	*time.Time
	LastAnalyze	*time.Time
	Columns		[]ColumnInfo
	Indexes		[]IndexInfo
}

TableDetail holds detailed information about a single table.

type TableInfo

type TableInfo struct {
	Schema		string
	Name		string
	TotalSize	int64
	LiveTuples	int64
	DeadTuples	int64
	SeqScan		int64
	IdxScan		int64
	LastVacuum	*time.Time
	LastAutoVacuum	*time.Time
}

TableInfo holds per-table statistics from pg_stat_user_tables.

type Transaction

type Transaction struct {
	ResourceBase
	XactStart	time.Time
	XactDuration	time.Duration
	QueryDuration	time.Duration
	QueryText	string
	LockCount	int
}// when this transaction began — unique with PID

Transaction represents an active transaction from pg_stat_activity.

github.com/fraser-isbester/tusk/internal/rules

package rules

No package overview.

Functions

func EnvForResource

func EnvForResource(rt ResourceType) (*cel.Env, error)

EnvForResource returns the appropriate CEL environment for the given resource type.

func LockEnv

func LockEnv() (*cel.Env, error)

LockEnv returns a CEL environment for evaluating rules against db.Lock resources.

func QueryEnv

func QueryEnv() (*cel.Env, error)

QueryEnv returns a CEL environment for evaluating rules against db.Query resources.

func TransactionEnv

func TransactionEnv() (*cel.Env, error)

TransactionEnv returns a CEL environment for evaluating rules against db.Transaction resources.

type CancelAction

type CancelAction struct{}

CancelAction calls pg_cancel_backend.

func (CancelAction) Execute

func (a *CancelAction) Execute(ctx context.Context, database *db.DB, pid int) error

func (CancelAction) Name

func (a *CancelAction) Name() string

type Engine

type Engine struct {

}// contains filtered or unexported fields

Engine evaluates rules against snapshots and manages violation history.

func NewEngine

func NewEngine(rules []Rule, database *db.DB, violationTTL time.Duration, maxViolations int) *Engine

NewEngine creates a new rules engine.

func (Engine) Evaluate

func (e *Engine) Evaluate(ctx context.Context, snap Snapshot)

Evaluate runs all rules against the snapshot.

func (Engine) ManualAction

func (e *Engine) ManualAction(ruleName string, pid int) string

ManualAction manually fires an action for a violation and appends events to the log. Returns the result message for display.

func (Engine) RecentViolations

func (e *Engine) RecentViolations() []Violation

RecentViolations returns violation history within TTL, newest first.

func (Engine) RuleCount

func (e *Engine) RuleCount() int

RuleCount returns the number of active rules.

func (Engine) Rules

func (e *Engine) Rules() []Rule

Rules returns a snapshot of the configured rules.

func (Engine) UpdateRules

func (e *Engine) UpdateRules(rules []Rule)

UpdateRules hot-swaps the rule set.

func (Engine) ViolatedPIDs

func (e *Engine) ViolatedPIDs() map[int]Violation

ViolatedPIDs returns a map of PIDs currently in active violation.

type EventKind

type EventKind string

EventKind identifies a type of violation lifecycle event.

type Executor

type Executor interface {
	Execute(ctx context.Context, database *db.DB, pid int) error
	Name() string
}

Executor is the interface for rule actions.

type LogAction

type LogAction struct{}

LogAction writes a log line to stderr.

func (LogAction) Execute

func (a *LogAction) Execute(_ context.Context, _ *db.DB, pid int) error

func (LogAction) Name

func (a *LogAction) Name() string

type ResourceType

type ResourceType string

ResourceType identifies the kind of Postgres resource a rule targets.

type Rule

type Rule struct {
	Name		string
	Enabled		bool
	Resource	ResourceType
	Program		cel.Program
	Expression	string
	Action		Executor
	Cooldown	time.Duration
	DryRun		bool
}

Rule binds a CEL expression to a resource type, an action, and cooldown config.

func BuildRules

func BuildRules(configs []RuleConfig, readonly bool) ([]Rule, error)

BuildRules compiles rule configs into executable rules. If readonly is true, all rules are forced to dry-run mode.

type RuleConfig

type RuleConfig struct {
	Name		string	`yaml:"name"`
	Enabled		*bool	`yaml:"enabled"`
	DryRun		bool	`yaml:"dry_run"`
	Resource	string	`yaml:"resource"`
	When		string	`yaml:"when"`
	Action		string	`yaml:"action"`
	Cooldown	string	`yaml:"cooldown"`
}

RuleConfig is the YAML representation of a rule.

type Snapshot

type Snapshot struct {
	Queries		[]db.Query
	Transactions	[]db.Transaction
	Locks		[]db.Lock
}

Snapshot holds the data fetched in one polling tick.

type TerminateAction

type TerminateAction struct{}

TerminateAction calls pg_terminate_backend.

func (TerminateAction) Execute

func (a *TerminateAction) Execute(ctx context.Context, database *db.DB, pid int) error

func (TerminateAction) Name

func (a *TerminateAction) Name() string

type Violation

type Violation struct {
	RuleName	string
	ResourceType	ResourceType
	PID		int
	Expression	string
	ActionName	string
	Active		bool
	DryRun		bool
	Events		[]ViolationEvent
	QuerySnap	*db.Query
	TransactionSnap	*db.Transaction
	LockSnap	*db.Lock
}

Violation records that a rule fired against a resource, with a full lifecycle audit log of events.

func (Violation) CreatedAt

func (v *Violation) CreatedAt() time.Time

CreatedAt returns the timestamp of the first event.

func (Violation) LastEvent

func (v *Violation) LastEvent() ViolationEvent

LastEvent returns the most recent event, or a zero event if empty.

type ViolationEvent

type ViolationEvent struct {
	Time	time.Time
	Kind	EventKind
	Message	string
}

ViolationEvent is a timestamped entry in a violation's audit log.

type ViolationStore

type ViolationStore struct {

}// contains filtered or unexported fields

ViolationStore retains violations with TTL eviction and cooldown dedup.

func NewViolationStore

func NewViolationStore(ttl time.Duration, maxSize int) *ViolationStore

NewViolationStore creates a new violation store.

func (ViolationStore) MarkActive

func (s *ViolationStore) MarkActive(activePIDs map[int]bool)

MarkActive updates the Active flag and appends a closed event for violations whose PID is no longer present.

func (ViolationStore) Prune

func (s *ViolationStore) Prune()

Prune removes violations whose last event is older than TTL.

func (ViolationStore) Recent

func (s *ViolationStore) Recent() []Violation

Recent returns violations within the TTL window, newest first.

func (ViolationStore) RecordOrUpdate

func (s *ViolationStore) RecordOrUpdate(v Violation, cooldown time.Duration) (*Violation, bool)

RecordOrUpdate finds an existing active violation for the same rule+PID and returns it for event appending, or creates a new one. Returns the violation pointer and whether the action should fire (not in cooldown).

func (ViolationStore) ViolatedPIDs

func (s *ViolationStore) ViolatedPIDs() map[int]Violation

ViolatedPIDs returns a map of PIDs currently in active violation.

github.com/fraser-isbester/tusk/internal/tui

package tui

No package overview.

type App

type App struct {

}// contains filtered or unexported fields

App is the root TUI application.

func NewApp

func NewApp(database *db.DB, profileName, profileColor, connUser string, readonly bool, engine *rules.Engine) *App

func (App) Run

func (a *App) Run() error

type Command

type Command struct {
	Name		string
	Aliases		[]string
	ViewName	string
}

Command represents a colon-command with a canonical name, aliases, and the view it maps to.

type CommandRegistry

type CommandRegistry struct {

}// contains filtered or unexported fields

CommandRegistry holds all registered colon-commands.

func NewCommandRegistry

func NewCommandRegistry() *CommandRegistry

NewCommandRegistry creates a CommandRegistry populated with the MVP commands.

func (CommandRegistry) Match

func (r *CommandRegistry) Match(input string) (string, bool)

Match performs a fuzzy-prefix match on the input against all command names and aliases. It returns the view name of the matched command and true if a unique match is found. If the input is ambiguous or matches nothing, it returns ("", false).

Examples:

"q"    -> ("queries", true)
"t"    -> ("tables", true)
"dash" -> ("dashboard", true)

type View

type View interface {
	Table() *tview.Table
	Start(app *tview.Application)
	Stop()
	ItemCount() int
	SetFilter(text string)
}

View is the interface all resource views implement.

github.com/fraser-isbester/tusk/internal/tui/theme

package theme

No package overview.

Variables

var (
	ColorLogo		= tcell.NewRGBColor(0x00, 0xD7, 0xFF)
	ColorLabel		= tcell.NewRGBColor(0xD7, 0x87, 0x00)
	ColorValue		= tcell.ColorWhite
	ColorDim		= tcell.NewRGBColor(0x58, 0x58, 0x58)
	ColorFg			= tcell.NewRGBColor(0xD0, 0xD0, 0xD0)
	ColorGreen		= tcell.NewRGBColor(0x00, 0xD7, 0x00)
	ColorYellow		= tcell.NewRGBColor(0xFF, 0xD7, 0x00)
	ColorRed		= tcell.NewRGBColor(0xFF, 0x5F, 0x5F)
	ColorHeaderBg		= tcell.NewRGBColor(0x30, 0x30, 0x30)
	ColorBorder		= tcell.NewRGBColor(0x00, 0x5F, 0xAF)
	ColorBorderActive	= tcell.NewRGBColor(0x00, 0x87, 0xAF)
	ColorSelectedBg		= tcell.NewRGBColor(0x00, 0x5F, 0xAF)
	ColorSelectedFg		= tcell.ColorWhite
	ColorTableHeader	= tcell.NewRGBColor(0xD7, 0x87, 0x00)
	SelectedStyle		= tcell.StyleDefault.Foreground(ColorSelectedFg).Background(ColorSelectedBg).Attributes(tcell.AttrBold)
)// cyan
// tcell styles

k9s-inspired color palette using tcell colors.

github.com/fraser-isbester/tusk/internal/tui/views

package views

No package overview.

Functions

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration into a concise human-readable string. Exported for use by the app-level header.

func NewLockDetailView

func NewLockDetailView(l db.Lock, dbConn *db.DB) *tview.Flex

NewLockDetailView creates a split-pane detail view for a lock.

func NewQueryDetailView

func NewQueryDetailView(q db.Query, dbConn *db.DB, history *db.QueryHistory, app *tview.Application, engine *rules.Engine, nav Navigator) *tview.Flex

NewQueryDetailView creates a split-pane detail view for a query.

func NewTableDetailView

func NewTableDetailView(schema, name string, dbConn *db.DB, app *tview.Application) *tview.Flex

NewTableDetailView creates a detail view for a table, loading data asynchronously.

func NewTransactionDetailView

func NewTransactionDetailView(t db.Transaction, dbConn *db.DB, history *db.QueryHistory, app *tview.Application, engine *rules.Engine, nav Navigator) *tview.Flex

NewTransactionDetailView creates a split-pane detail view for a transaction. The main pane shows all queries executed in this transaction (from history).

type Connections

type Connections struct {

}// contains filtered or unexported fields

Connections is the connections view.

func NewConnectionsView

func NewConnectionsView(database *db.DB) *Connections

NewConnectionsView creates a new Connections view.

func (Connections) ItemCount

func (v *Connections) ItemCount() int

ItemCount returns the number of connection groups.

func (Connections) SelectedUser

func (v *Connections) SelectedUser() (string, bool)

SelectedUser returns the user from the currently selected connection group.

func (Connections) SetFilter

func (v *Connections) SetFilter(text string)

SetFilter sets the filter text for searching across all columns.

func (Connections) Start

func (v *Connections) Start(app *tview.Application)

Start begins the background refresh loop.

func (Connections) Stop

func (v *Connections) Stop()

Stop stops the background refresh loop.

func (Connections) Table

func (v *Connections) Table() *tview.Table

Table returns the underlying tview.Table.

type Databases

type Databases struct {

}// contains filtered or unexported fields

Databases is the databases view.

func NewDatabasesView

func NewDatabasesView(database *db.DB) *Databases

NewDatabasesView creates a new Databases view.

func (Databases) ItemCount

func (v *Databases) ItemCount() int

ItemCount returns the number of databases.

func (Databases) SetFilter

func (v *Databases) SetFilter(text string)

SetFilter sets the filter text for searching across all columns.

func (Databases) Start

func (v *Databases) Start(app *tview.Application)

Start begins the background refresh loop.

func (Databases) Stop

func (v *Databases) Stop()

Stop stops the background refresh loop.

func (Databases) Table

func (v *Databases) Table() *tview.Table

Table returns the underlying tview.Table.

type Indexes

type Indexes struct {

}// contains filtered or unexported fields

Indexes is the index analysis view.

func NewIndexesView

func NewIndexesView(database *db.DB) *Indexes

NewIndexesView creates a new Indexes view.

func (Indexes) ItemCount

func (v *Indexes) ItemCount() int

ItemCount returns the number of indexes.

func (Indexes) SetFilter

func (v *Indexes) SetFilter(text string)

SetFilter sets the filter text for searching across all columns.

func (Indexes) Start

func (v *Indexes) Start(app *tview.Application)

Start begins the periodic refresh loop.

func (Indexes) Stop

func (v *Indexes) Stop()

Stop stops the periodic refresh loop.

func (Indexes) Table

func (v *Indexes) Table() *tview.Table

Table returns the underlying tview.Table.

type Locks

type Locks struct {

}// contains filtered or unexported fields

Locks is the lock contention view.

func NewLocksView

func NewLocksView(database *db.DB) *Locks

NewLocksView creates a new Locks view.

func (Locks) ItemCount

func (v *Locks) ItemCount() int

ItemCount returns the number of lock entries.

func (Locks) SelectedLock

func (v *Locks) SelectedLock() (db.Lock, bool)

SelectedLock returns the lock info at the currently selected row.

func (Locks) SetFilter

func (v *Locks) SetFilter(text string)

SetFilter sets the filter text for searching across all columns.

func (Locks) Start

func (v *Locks) Start(app *tview.Application)

Start begins the periodic refresh loop.

func (Locks) Stop

func (v *Locks) Stop()

Stop stops the periodic refresh loop.

func (Locks) Table

func (v *Locks) Table() *tview.Table

Table returns the underlying tview.Table.

type Navigator

type Navigator func(name string, detail tview.Primitive)

Navigator is a callback for pushing detail pages onto the app's view stack.

type Queries

type Queries struct {

}// contains filtered or unexported fields

Queries is the active queries view.

func NewQueriesView

func NewQueriesView(database *db.DB) *Queries

NewQueriesView creates a new Queries view.

func (Queries) ItemCount

func (v *Queries) ItemCount() int

ItemCount returns the number of visible queries.

func (Queries) SelectedQuery

func (v *Queries) SelectedQuery() (db.Query, bool)

SelectedQuery returns the query at the currently selected row.

func (Queries) SetEngine

func (v *Queries) SetEngine(e *rules.Engine)

SetEngine sets the rules engine for violation indicators.

func (Queries) SetFilter

func (v *Queries) SetFilter(text string)

SetFilter sets the filter text for searching across all columns.

func (Queries) SetQueryHistory

func (v *Queries) SetQueryHistory(h *db.QueryHistory)

SetQueryHistory sets the shared query history tracker.

func (Queries) SetUserFilter

func (v *Queries) SetUserFilter(user string)

SetUserFilter restricts the view to queries from a specific user.

func (Queries) Start

func (v *Queries) Start(app *tview.Application)

Start begins the background refresh loop.

func (Queries) Stop

func (v *Queries) Stop()

Stop stops the background refresh loop.

func (Queries) Table

func (v *Queries) Table() *tview.Table

Table returns the underlying tview.Table.

type Roles

type Roles struct {

}// contains filtered or unexported fields

Roles is the roles view.

func NewRolesView

func NewRolesView(database *db.DB) *Roles

NewRolesView creates a new Roles view.

func (Roles) ItemCount

func (v *Roles) ItemCount() int

ItemCount returns the number of roles.

func (Roles) SelectedRole

func (v *Roles) SelectedRole() (string, bool)

SelectedRole returns the role name at the currently selected row.

func (Roles) SetFilter

func (v *Roles) SetFilter(text string)

SetFilter sets the filter text for searching across all columns.

func (Roles) Start

func (v *Roles) Start(app *tview.Application)

Start begins the background refresh loop.

func (Roles) Stop

func (v *Roles) Stop()

Stop stops the background refresh loop.

func (Roles) Table

func (v *Roles) Table() *tview.Table

Table returns the underlying tview.Table.

type Rules

type Rules struct {

}// contains filtered or unexported fields

Rules is the configured rules view.

func NewRulesView

func NewRulesView(engine *rules.Engine) *Rules

NewRulesView creates a new Rules view.

func (Rules) ItemCount

func (v *Rules) ItemCount() int

ItemCount returns the number of configured rules.

func (Rules) SelectedRule

func (v *Rules) SelectedRule() (string, bool)

SelectedRule returns the rule name at the currently selected row.

func (Rules) SetFilter

func (v *Rules) SetFilter(_ string)

SetFilter is a no-op for the rules view.

func (Rules) Start

func (v *Rules) Start(app *tview.Application)

Start begins the periodic refresh loop.

func (Rules) Stop

func (v *Rules) Stop()

Stop stops the periodic refresh loop.

func (Rules) Table

func (v *Rules) Table() *tview.Table

Table returns the underlying tview.Table.

type SlowQueries

type SlowQueries struct {

}// contains filtered or unexported fields

SlowQueries is the slow queries view.

func NewSlowQueriesView

func NewSlowQueriesView(database *db.DB) *SlowQueries

NewSlowQueriesView creates a new SlowQueries view.

func (SlowQueries) ItemCount

func (v *SlowQueries) ItemCount() int

ItemCount returns the number of slow queries.

func (SlowQueries) SetFilter

func (v *SlowQueries) SetFilter(text string)

SetFilter sets the filter text for searching across all columns.

func (SlowQueries) Start

func (v *SlowQueries) Start(app *tview.Application)

Start begins the periodic refresh loop.

func (SlowQueries) Stop

func (v *SlowQueries) Stop()

Stop stops the periodic refresh loop.

func (SlowQueries) Table

func (v *SlowQueries) Table() *tview.Table

Table returns the underlying tview.Table.

type Tables

type Tables struct {

}// contains filtered or unexported fields

Tables is the tables view.

func NewTablesView

func NewTablesView(database *db.DB) *Tables

NewTablesView creates a new Tables view.

func (Tables) ItemCount

func (v *Tables) ItemCount() int

ItemCount returns the number of tables.

func (Tables) SelectedTable

func (v *Tables) SelectedTable() (db.TableInfo, bool)

SelectedTable returns the table info at the currently selected row.

func (Tables) SetFilter

func (v *Tables) SetFilter(text string)

SetFilter sets the filter text for searching across all columns.

func (Tables) Start

func (v *Tables) Start(app *tview.Application)

Start begins the periodic refresh loop.

func (Tables) Stop

func (v *Tables) Stop()

Stop stops the periodic refresh loop.

func (Tables) Table

func (v *Tables) Table() *tview.Table

Table returns the underlying tview.Table.

type Transactions

type Transactions struct {

}// contains filtered or unexported fields

Transactions is the transaction monitor view.

func NewTransactionsView

func NewTransactionsView(database *db.DB) *Transactions

NewTransactionsView creates a new Transactions view.

func (Transactions) ItemCount

func (v *Transactions) ItemCount() int

ItemCount returns the number of transactions.

func (Transactions) SelectedTransaction

func (v *Transactions) SelectedTransaction() (db.Transaction, bool)

SelectedTransaction returns the transaction at the currently selected row.

func (Transactions) SetEngine

func (v *Transactions) SetEngine(e *rules.Engine)

SetEngine sets the rules engine for violation indicators.

func (Transactions) SetFilter

func (v *Transactions) SetFilter(text string)

SetFilter sets the filter text for searching across all columns.

func (Transactions) SetQueryHistory

func (v *Transactions) SetQueryHistory(h *db.QueryHistory)

SetQueryHistory sets the shared query history tracker.

func (Transactions) Start

func (v *Transactions) Start(app *tview.Application)

Start begins the periodic refresh loop.

func (Transactions) Stop

func (v *Transactions) Stop()

Stop stops the periodic refresh loop.

func (Transactions) Table

func (v *Transactions) Table() *tview.Table

Table returns the underlying tview.Table.

type Violations

type Violations struct {

}// contains filtered or unexported fields

Violations is the violation history view.

func NewViolationsView

func NewViolationsView(engine *rules.Engine) *Violations

NewViolationsView creates a new Violations view.

func (Violations) ItemCount

func (v *Violations) ItemCount() int

ItemCount returns the number of recent violations.

func (Violations) SelectedViolation

func (v *Violations) SelectedViolation() (rules.Violation, bool)

SelectedViolation returns the violation at the currently selected row.

func (Violations) SetFilter

func (v *Violations) SetFilter(text string)

SetFilter filters violations by rule name (substring match).

func (Violations) SetOnSelect

func (v *Violations) SetOnSelect(fn func(rules.Violation))

SetOnSelect sets a callback invoked when Enter is pressed on a violation row.

func (Violations) Start

func (v *Violations) Start(app *tview.Application)

Start begins the periodic refresh loop.

func (Violations) Stop

func (v *Violations) Stop()

Stop stops the periodic refresh loop.

func (Violations) Table

func (v *Violations) Table() *tview.Table

Table returns the underlying tview.Table.