postgres

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 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 ApplicationRepository added in v1.2.0

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

ApplicationRepository implements ports.ApplicationRepository for PostgreSQL.

func NewApplicationRepository added in v1.2.0

func NewApplicationRepository(db *sql.DB) *ApplicationRepository

NewApplicationRepository creates a new ApplicationRepository.

func (*ApplicationRepository) FindByID added in v1.2.0

FindByID retrieves an application by its ID.

func (*ApplicationRepository) FindBySlug added in v1.2.0

FindBySlug retrieves an application by its slug.

func (*ApplicationRepository) List added in v1.2.0

func (r *ApplicationRepository) List(ctx context.Context, limit int) ([]*domain.Application, error)

List retrieves all applications, limited by the specified count.

func (*ApplicationRepository) Save added in v1.2.0

Save persists an application (insert or update).

func (*ApplicationRepository) UpdateStars added in v1.2.0

func (r *ApplicationRepository) UpdateStars(ctx context.Context, id domain.ApplicationID, stars int) error

UpdateStars updates only the GitHub stars count and timestamp.

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) GetActiveInstancesCount added in v1.2.0

func (r *DashboardReader) GetActiveInstancesCount(ctx context.Context, appSlug string) (int, error)

GetActiveInstancesCount returns the count of active instances for an app.

func (*DashboardReader) GetAggregatedMetric added in v1.2.0

func (r *DashboardReader) GetAggregatedMetric(ctx context.Context, appSlug, metricName string) (float64, error)

GetAggregatedMetric sums a specific metric across all active instances of an app.

func (*DashboardReader) GetCombinedStats added in v1.2.0

func (r *DashboardReader) GetCombinedStats(ctx context.Context, appSlug, metricName string) (float64, int, error)

GetCombinedStats returns both an aggregated metric and instance count.

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) GetMostUsedVersion added in v1.2.0

func (r *DashboardReader) GetMostUsedVersion(ctx context.Context, appSlug string) (string, error)

GetMostUsedVersion returns the most commonly used version for an app.

func (*DashboardReader) GetStats

GetStats returns aggregated dashboard statistics.

func (*DashboardReader) ListInstances

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

ListInstances returns instances with their latest metrics. offset and limit are used for pagination. appName filters by app name (empty = all apps). search filters by instance_id, version, environment, or deployment_mode.

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) Delete added in v1.2.2

Delete removes an instance and all its associated snapshots.

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) ApplicationRepository added in v1.2.0

func (s *Store) ApplicationRepository() *ApplicationRepository

ApplicationRepository returns an ApplicationRepository backed by this store.

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