postgres

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: AGPL-3.0, AGPL-3.0-or-later Imports: 9 Imported by: 0

Documentation

Overview

Package postgres provides PostgreSQL implementations of the repository interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DashboardReader

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

DashboardReader implements ports.DashboardReader for PostgreSQL.

func NewDashboardReader

func NewDashboardReader(db *sql.DB) *DashboardReader

NewDashboardReader creates a new DashboardReader.

func (*DashboardReader) GetMetricsTimeSeries

func (r *DashboardReader) GetMetricsTimeSeries(ctx context.Context, appName string, since time.Time) (ports.MetricsTimeSeries, error)

GetMetricsTimeSeries returns time-series metrics for an app.

func (*DashboardReader) GetStats

GetStats returns aggregated dashboard statistics.

func (*DashboardReader) ListInstances

func (r *DashboardReader) ListInstances(ctx context.Context, limit int) ([]ports.InstanceSummary, error)

ListInstances returns instances with their latest metrics.

type InstanceRepository

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

InstanceRepository implements ports.InstanceRepository for PostgreSQL.

func NewInstanceRepository

func NewInstanceRepository(db *sql.DB) *InstanceRepository

NewInstanceRepository creates a new InstanceRepository.

func (*InstanceRepository) FindByID

FindByID retrieves an instance by its ID.

func (*InstanceRepository) GetPublicKey

GetPublicKey retrieves the public key for an instance.

func (*InstanceRepository) Save

func (r *InstanceRepository) Save(ctx context.Context, instance *domain.Instance) error

Save persists an instance (insert or update).

func (*InstanceRepository) UpdateStatus

func (r *InstanceRepository) UpdateStatus(ctx context.Context, id domain.InstanceID, status domain.InstanceStatus) error

UpdateStatus updates the status and last_seen_at timestamp.

type SnapshotRepository

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

SnapshotRepository implements ports.SnapshotRepository for PostgreSQL.

func NewSnapshotRepository

func NewSnapshotRepository(db *sql.DB) *SnapshotRepository

NewSnapshotRepository creates a new SnapshotRepository.

func (*SnapshotRepository) FindByInstanceID

func (r *SnapshotRepository) FindByInstanceID(ctx context.Context, id domain.InstanceID, limit int) ([]*domain.Snapshot, error)

FindByInstanceID retrieves snapshots for an instance.

func (*SnapshotRepository) GetLatestByInstanceID

func (r *SnapshotRepository) GetLatestByInstanceID(ctx context.Context, id domain.InstanceID) (*domain.Snapshot, error)

GetLatestByInstanceID retrieves the most recent snapshot for an instance.

func (*SnapshotRepository) Save

func (r *SnapshotRepository) Save(ctx context.Context, snapshot *domain.Snapshot) error

Save persists a snapshot and updates the instance heartbeat.

type Store

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

Store holds the database connection and provides access to repositories.

func NewStore

func NewStore(connStr string) (*Store, error)

NewStore creates a new Store with a database connection.

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection.

func (*Store) DB

func (s *Store) DB() *sql.DB

DB returns the underlying database connection for advanced use cases.

func (*Store) DashboardReader

func (s *Store) DashboardReader() *DashboardReader

DashboardReader returns a DashboardReader backed by this store.

func (*Store) InstanceRepository

func (s *Store) InstanceRepository() *InstanceRepository

InstanceRepository returns an InstanceRepository backed by this store.

func (*Store) SnapshotRepository

func (s *Store) SnapshotRepository() *SnapshotRepository

SnapshotRepository returns a SnapshotRepository backed by this store.

Jump to

Keyboard shortcuts

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