Documentation
¶
Overview ¶
Package postgres is the PostgreSQL-backed implementation of storage.Repository
Index ¶
- type Store
- func (s *Store) Close() error
- func (s *Store) DB() *sql.DB
- func (s *Store) GetCluster(ctx context.Context, id string) (model.Cluster, error)
- func (s *Store) LatestAnalysisForCluster(ctx context.Context, clusterID string) (*model.Analysis, error)
- func (s *Store) ListClusters(ctx context.Context, filter storage.ClusterFilter) ([]model.Cluster, int64, error)
- func (s *Store) ListEventsByCluster(ctx context.Context, clusterID string, filter storage.EventFilter) ([]model.LogEvent, error)
- func (s *Store) ListRecentAnalyses(ctx context.Context, limit int) ([]model.Analysis, error)
- func (s *Store) Ping(ctx context.Context) error
- func (s *Store) Pool() *pgxpool.Pool
- func (s *Store) PruneStaleClusters(ctx context.Context, olderThan time.Time) (int64, error)
- func (s *Store) SaveAnalysis(ctx context.Context, a model.Analysis) error
- func (s *Store) SaveEvent(ctx context.Context, e model.LogEvent, clusterID string) error
- func (s *Store) UpsertCluster(ctx context.Context, c model.Cluster) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the Postgres-backed Repository implementation.
func (*Store) GetCluster ¶
GetCluster returns a cluster by its ID.
func (*Store) LatestAnalysisForCluster ¶
func (s *Store) LatestAnalysisForCluster(ctx context.Context, clusterID string) (*model.Analysis, error)
LatestAnalysisForCluster returns the analysis with the greatest window_end for the given cluster
func (*Store) ListClusters ¶
func (s *Store) ListClusters(ctx context.Context, filter storage.ClusterFilter) ([]model.Cluster, int64, error)
ListClusters returns clusters matching the filter, plus the total row count. Services and Levels filters are applied in Go after scanning because they would require a JSON parser in SQL; both columns are TEXT JSON to keep the schema identical between SQLite and Postgres, the reported total is the pre-filter count for that reason.
func (*Store) ListEventsByCluster ¶
func (s *Store) ListEventsByCluster(ctx context.Context, clusterID string, filter storage.EventFilter) ([]model.LogEvent, error)
ListEventsByCluster returns events for a cluster ordered by ts DESC, default time range: last 1 hour, limit: 200
func (*Store) ListRecentAnalyses ¶
ListRecentAnalyses returns the most recently created analyses ordered by created_at DESC
func (*Store) PruneStaleClusters ¶
PruneStaleClusters deletes clusters whose last_seen is before olderThan, returns the number of rows deleted.
func (*Store) SaveAnalysis ¶
SaveAnalysis inserts an analysis; the existing row is updated so re-runs for the same window are idempotent.
func (*Store) UpsertCluster ¶
UpsertCluster inserts a new cluster or updates all mutable fields when a row with the same id already exists. Cluster ID (assigned once by the in-memory Drain tree) is the stable key; fingerprint is mutable because Drain generalizes templates as new events match a group.