sqlite

package
v1.2.12 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(db *sql.DB, logger *slog.Logger) error

Migrate runs all pending database migrations using golang-migrate v4. On the first run after upgrading from the custom migration system, it bootstraps the schema_migrations table from the old schema_version table.

func NullableString

func NullableString(s string) interface{}

NullableString returns nil if s is empty, otherwise returns s. Used for nullable TEXT columns in SQLite.

func StartRetentionCleanupWithOpts

func StartRetentionCleanupWithOpts(ctx context.Context, store *ContainerStore, db *DB, logger *slog.Logger, opts RetentionOpts)

StartRetentionCleanupWithOpts starts retention cleanup with all store types.

Types

type AcknowledgmentStoreImpl added in v1.1.0

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

AcknowledgmentStoreImpl implements security.AcknowledgmentStore using SQLite.

func NewAcknowledgmentStore added in v1.1.0

func NewAcknowledgmentStore(d *DB) *AcknowledgmentStoreImpl

NewAcknowledgmentStore creates a new SQLite-backed acknowledgment store.

func (*AcknowledgmentStoreImpl) DeleteAcknowledgment added in v1.1.0

func (s *AcknowledgmentStoreImpl) DeleteAcknowledgment(ctx context.Context, id int64) error

func (*AcknowledgmentStoreImpl) GetAcknowledgment added in v1.1.0

func (s *AcknowledgmentStoreImpl) GetAcknowledgment(ctx context.Context, id int64) (*security.RiskAcknowledgment, error)

func (*AcknowledgmentStoreImpl) InsertAcknowledgment added in v1.1.0

func (s *AcknowledgmentStoreImpl) InsertAcknowledgment(ctx context.Context, ack *security.RiskAcknowledgment) (int64, error)

func (*AcknowledgmentStoreImpl) IsAcknowledged added in v1.1.0

func (s *AcknowledgmentStoreImpl) IsAcknowledged(ctx context.Context, containerExternalID, findingType, findingKey string) (bool, error)

func (*AcknowledgmentStoreImpl) ListAcknowledgments added in v1.1.0

func (s *AcknowledgmentStoreImpl) ListAcknowledgments(ctx context.Context, containerExternalID string) ([]*security.RiskAcknowledgment, error)

type AlertStoreImpl

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

AlertStoreImpl implements alert.AlertStore using SQLite.

func NewAlertStore

func NewAlertStore(d *DB) *AlertStoreImpl

NewAlertStore creates a new SQLite-backed alert store.

func (*AlertStoreImpl) AcknowledgeAlert added in v1.0.1

func (s *AlertStoreImpl) AcknowledgeAlert(ctx context.Context, id int64, by string, at time.Time) error

func (*AlertStoreImpl) DeleteAlertsOlderThan

func (s *AlertStoreImpl) DeleteAlertsOlderThan(ctx context.Context, before time.Time) (int64, error)

func (*AlertStoreImpl) GetActiveAlert

func (s *AlertStoreImpl) GetActiveAlert(ctx context.Context, source, alertType, entityType string, entityID int64) (*alert.Alert, error)

func (*AlertStoreImpl) GetAlert

func (s *AlertStoreImpl) GetAlert(ctx context.Context, id int64) (*alert.Alert, error)

func (*AlertStoreImpl) InsertAlert

func (s *AlertStoreImpl) InsertAlert(ctx context.Context, a *alert.Alert) (int64, error)

func (*AlertStoreImpl) ListActiveAlerts

func (s *AlertStoreImpl) ListActiveAlerts(ctx context.Context) ([]*alert.Alert, error)

func (*AlertStoreImpl) ListAlerts

func (s *AlertStoreImpl) ListAlerts(ctx context.Context, opts alert.ListAlertsOpts) ([]*alert.Alert, error)

func (*AlertStoreImpl) ListUnacknowledgedActiveAlerts added in v1.0.1

func (s *AlertStoreImpl) ListUnacknowledgedActiveAlerts(ctx context.Context) ([]*alert.Alert, error)

func (*AlertStoreImpl) SetEscalatedAt added in v1.0.1

func (s *AlertStoreImpl) SetEscalatedAt(ctx context.Context, id int64, at time.Time) error

func (*AlertStoreImpl) UpdateAlertSeverity

func (s *AlertStoreImpl) UpdateAlertSeverity(ctx context.Context, id int64, severity, message string) error

func (*AlertStoreImpl) UpdateAlertStatus

func (s *AlertStoreImpl) UpdateAlertStatus(ctx context.Context, id int64, status string, resolvedAt *time.Time, resolvedByID *int64) error

type CertificateStore

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

CertificateStore implements certificate.CertificateStore using SQLite.

func NewCertificateStore

func NewCertificateStore(d *DB) *CertificateStore

NewCertificateStore creates a new SQLite-backed certificate store.

func (*CertificateStore) CountConfigured added in v1.2.7

func (s *CertificateStore) CountConfigured(ctx context.Context) (int, error)

CountConfigured returns the number of certificate monitors. Operator-created and auto-detected entries are both counted; the table uses hard-delete only, so no soft-delete filter is needed. Used by the telemetry subsystem; see specs/015-shm-telemetry.

func (*CertificateStore) CountStandaloneMonitors added in v1.2.2

func (s *CertificateStore) CountStandaloneMonitors(ctx context.Context) (int, error)

func (*CertificateStore) CreateMonitor

func (s *CertificateStore) CreateMonitor(ctx context.Context, m *certificate.CertMonitor) (int64, error)

func (*CertificateStore) DeleteCheckResultsBefore

func (s *CertificateStore) DeleteCheckResultsBefore(ctx context.Context, before time.Time, batchSize int) (int64, error)

func (*CertificateStore) DeleteMonitor added in v1.2.5

func (s *CertificateStore) DeleteMonitor(ctx context.Context, id int64) error

DeleteMonitor hard-deletes a certificate monitor. Associated check results and chain entries are removed via ON DELETE CASCADE.

func (*CertificateStore) GetChainEntries

func (s *CertificateStore) GetChainEntries(ctx context.Context, checkResultID int64) ([]*certificate.CertChainEntry, error)

func (*CertificateStore) GetLatestCheckResult

func (s *CertificateStore) GetLatestCheckResult(ctx context.Context, monitorID int64) (*certificate.CertCheckResult, error)

func (*CertificateStore) GetMonitorByEndpointID

func (s *CertificateStore) GetMonitorByEndpointID(ctx context.Context, endpointID int64) (*certificate.CertMonitor, error)

func (*CertificateStore) GetMonitorByHostPort

func (s *CertificateStore) GetMonitorByHostPort(ctx context.Context, hostname string, port int) (*certificate.CertMonitor, error)

func (*CertificateStore) GetMonitorByID

func (s *CertificateStore) GetMonitorByID(ctx context.Context, id int64) (*certificate.CertMonitor, error)

func (*CertificateStore) InsertChainEntries

func (s *CertificateStore) InsertChainEntries(ctx context.Context, entries []*certificate.CertChainEntry) error

func (*CertificateStore) InsertCheckResult

func (s *CertificateStore) InsertCheckResult(ctx context.Context, result *certificate.CertCheckResult) (int64, error)

func (*CertificateStore) ListCheckResults

func (s *CertificateStore) ListCheckResults(ctx context.Context, monitorID int64, opts certificate.ListChecksOpts) ([]*certificate.CertCheckResult, int, error)

func (*CertificateStore) ListDueScheduledMonitors

func (s *CertificateStore) ListDueScheduledMonitors(ctx context.Context, now time.Time) ([]*certificate.CertMonitor, error)

func (*CertificateStore) ListMonitors

func (*CertificateStore) ListMonitorsByExternalID

func (s *CertificateStore) ListMonitorsByExternalID(ctx context.Context, externalID string) ([]*certificate.CertMonitor, error)

func (*CertificateStore) UpdateMonitor

func (s *CertificateStore) UpdateMonitor(ctx context.Context, m *certificate.CertMonitor) error

type ChannelStoreImpl

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

ChannelStoreImpl implements alert.ChannelStore using SQLite.

func NewChannelStore

func NewChannelStore(d *DB) *ChannelStoreImpl

NewChannelStore creates a new SQLite-backed channel store.

func (*ChannelStoreImpl) DeleteChannel

func (s *ChannelStoreImpl) DeleteChannel(ctx context.Context, id int64) error

func (*ChannelStoreImpl) GetChannel

func (*ChannelStoreImpl) GetChannelHealth

func (s *ChannelStoreImpl) GetChannelHealth(ctx context.Context, channelID int64) (string, error)

func (*ChannelStoreImpl) InsertChannel

func (s *ChannelStoreImpl) InsertChannel(ctx context.Context, ch *alert.NotificationChannel) (int64, error)

func (*ChannelStoreImpl) InsertDelivery

func (s *ChannelStoreImpl) InsertDelivery(ctx context.Context, d *alert.NotificationDelivery) (int64, error)

func (*ChannelStoreImpl) ListChannels

func (s *ChannelStoreImpl) ListChannels(ctx context.Context) ([]*alert.NotificationChannel, error)

func (*ChannelStoreImpl) ListDeliveriesByAlert

func (s *ChannelStoreImpl) ListDeliveriesByAlert(ctx context.Context, alertID int64) ([]*alert.NotificationDelivery, error)

func (*ChannelStoreImpl) UpdateChannel

func (s *ChannelStoreImpl) UpdateChannel(ctx context.Context, ch *alert.NotificationChannel) error

func (*ChannelStoreImpl) UpdateDelivery

func (s *ChannelStoreImpl) UpdateDelivery(ctx context.Context, d *alert.NotificationDelivery) error

type ContainerStore

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

ContainerStore implements container.ContainerStore using SQLite.

func NewContainerStore

func NewContainerStore(d *DB) *ContainerStore

NewContainerStore creates a new SQLite-backed container store.

func (*ContainerStore) ArchiveContainer

func (s *ContainerStore) ArchiveContainer(ctx context.Context, externalID string, archivedAt time.Time) error

func (*ContainerStore) CountConfigured added in v1.2.7

func (s *ContainerStore) CountConfigured(ctx context.Context) (int, error)

CountConfigured returns the number of non-archived auto-discovered containers. Used by the telemetry subsystem; see specs/015-shm-telemetry.

func (*ContainerStore) CountRestartsSince

func (s *ContainerStore) CountRestartsSince(ctx context.Context, containerID int64, since time.Time) (int, error)

func (*ContainerStore) DeleteArchivedContainersBefore

func (s *ContainerStore) DeleteArchivedContainersBefore(ctx context.Context, before time.Time) (int64, error)

func (*ContainerStore) DeleteContainerByID

func (s *ContainerStore) DeleteContainerByID(ctx context.Context, id int64) error

func (*ContainerStore) DeleteTransitionsBefore

func (s *ContainerStore) DeleteTransitionsBefore(ctx context.Context, before time.Time, batchSize int) (int64, error)

func (*ContainerStore) GetContainerByExternalID

func (s *ContainerStore) GetContainerByExternalID(ctx context.Context, externalID string) (*container.Container, error)

func (*ContainerStore) GetContainerByID

func (s *ContainerStore) GetContainerByID(ctx context.Context, id int64) (*container.Container, error)

func (*ContainerStore) GetTransitionsInWindow

func (s *ContainerStore) GetTransitionsInWindow(ctx context.Context, containerID int64, from, to time.Time) ([]*container.StateTransition, error)

func (*ContainerStore) InsertContainer

func (s *ContainerStore) InsertContainer(ctx context.Context, c *container.Container) (int64, error)

func (*ContainerStore) InsertTransition

func (s *ContainerStore) InsertTransition(ctx context.Context, t *container.StateTransition) (int64, error)

InsertTransition records a state transition.

func (*ContainerStore) ListContainers

func (*ContainerStore) ListTransitionsByContainer

func (s *ContainerStore) ListTransitionsByContainer(ctx context.Context, containerID int64, opts container.ListTransitionsOpts) ([]*container.StateTransition, int, error)

func (*ContainerStore) UpdateContainer

func (s *ContainerStore) UpdateContainer(ctx context.Context, c *container.Container) error

type DB

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

DB wraps a SQLite database connection with maintenant configuration.

func Open

func Open(dbPath string, logger *slog.Logger) (*DB, error)

Open creates and configures a SQLite database connection with WAL mode.

func (*DB) Close

func (d *DB) Close() error

Close closes the database connection.

func (*DB) ReadDB

func (d *DB) ReadDB() *sql.DB

ReadDB returns the underlying sql.DB for read operations.

func (*DB) StartWriter

func (d *DB) StartWriter(ctx context.Context)

StartWriter starts the single-writer goroutine.

func (*DB) Writer

func (d *DB) Writer() *Writer

Writer returns the serialized to write channel.

type DailyUptime

type DailyUptime struct {
	Date          string   `json:"date"`
	UptimePercent *float64 `json:"uptime_percent"`
	IncidentCount int      `json:"incident_count"`
}

DailyUptime represents a single day's uptime aggregation.

type EndpointStore

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

EndpointStore implements endpoint.EndpointStore using SQLite.

func NewEndpointStore

func NewEndpointStore(d *DB) *EndpointStore

NewEndpointStore creates a new SQLite-backed endpoint store.

func (*EndpointStore) CountActiveEndpoints added in v1.2.2

func (s *EndpointStore) CountActiveEndpoints(ctx context.Context) (int, error)

func (*EndpointStore) CountConfigured added in v1.2.7

func (s *EndpointStore) CountConfigured(ctx context.Context) (int, error)

CountConfigured returns the number of operator-configured active endpoints. Soft-deleted (active=0) entries pending retention cleanup are excluded. Used by the telemetry subsystem; see specs/015-shm-telemetry.

func (*EndpointStore) DeactivateEndpoint

func (s *EndpointStore) DeactivateEndpoint(ctx context.Context, id int64) error

func (*EndpointStore) DeleteCheckResultsBefore

func (s *EndpointStore) DeleteCheckResultsBefore(ctx context.Context, before time.Time, batchSize int) (int64, error)

func (*EndpointStore) DeleteInactiveEndpointsBefore

func (s *EndpointStore) DeleteInactiveEndpointsBefore(ctx context.Context, before time.Time) (int64, error)

func (*EndpointStore) DeleteStandaloneEndpoint added in v1.1.2

func (s *EndpointStore) DeleteStandaloneEndpoint(ctx context.Context, id int64) error

DeleteStandaloneEndpoint permanently removes a standalone endpoint and its check results.

func (*EndpointStore) GetCheckResultsInWindow

func (s *EndpointStore) GetCheckResultsInWindow(ctx context.Context, endpointID int64, from, to time.Time) (int, int, error)

func (*EndpointStore) GetEndpointByID

func (s *EndpointStore) GetEndpointByID(ctx context.Context, id int64) (*endpoint.Endpoint, error)

func (*EndpointStore) GetEndpointByIdentity

func (s *EndpointStore) GetEndpointByIdentity(ctx context.Context, containerName, labelKey string) (*endpoint.Endpoint, error)

func (*EndpointStore) GetSparklineData

func (s *EndpointStore) GetSparklineData(ctx context.Context, limit int) (map[int64][]float64, error)

GetSparklineData returns the last N response_time_ms values per active endpoint.

func (*EndpointStore) InsertCheckResult

func (s *EndpointStore) InsertCheckResult(ctx context.Context, result *endpoint.CheckResult) (int64, error)

func (*EndpointStore) InsertStandaloneEndpoint added in v1.1.2

func (s *EndpointStore) InsertStandaloneEndpoint(ctx context.Context, e *endpoint.Endpoint) (int64, error)

InsertStandaloneEndpoint creates a manually-defined endpoint (not from container labels).

func (*EndpointStore) ListCheckResults

func (s *EndpointStore) ListCheckResults(ctx context.Context, endpointID int64, opts endpoint.ListChecksOpts) ([]*endpoint.CheckResult, int, error)

func (*EndpointStore) ListEndpoints

func (s *EndpointStore) ListEndpoints(ctx context.Context, opts endpoint.ListEndpointsOpts) ([]*endpoint.Endpoint, error)

func (*EndpointStore) ListEndpointsByExternalID

func (s *EndpointStore) ListEndpointsByExternalID(ctx context.Context, externalID string) ([]*endpoint.Endpoint, error)

func (*EndpointStore) UpdateCheckResult

func (s *EndpointStore) UpdateCheckResult(ctx context.Context, id int64, status endpoint.EndpointStatus,
	alertState endpoint.AlertState, consecutiveFailures, consecutiveSuccesses int,
	responseTimeMs int64, httpStatus *int, lastError string) error

func (*EndpointStore) UpdateStandaloneEndpoint added in v1.1.2

func (s *EndpointStore) UpdateStandaloneEndpoint(ctx context.Context, id int64, name, target string, endpointType endpoint.EndpointType, configJSON string) error

UpdateStandaloneEndpoint updates a standalone endpoint's mutable fields.

func (*EndpointStore) UpsertEndpoint

func (s *EndpointStore) UpsertEndpoint(ctx context.Context, e *endpoint.Endpoint) (int64, error)

type EscalationStore added in v1.2.12

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

EscalationStore implements escalation.Store using SQLite.

func NewEscalationStore added in v1.2.12

func NewEscalationStore(d *DB) *EscalationStore

NewEscalationStore creates a new SQLite-backed escalation store.

func (*EscalationStore) BulkDeactivateAllPolicies added in v1.2.12

func (s *EscalationStore) BulkDeactivateAllPolicies(ctx context.Context) error

func (*EscalationStore) BulkRestorePoliciesFromDowngrade added in v1.2.12

func (s *EscalationStore) BulkRestorePoliciesFromDowngrade(ctx context.Context) error

func (*EscalationStore) BulkStopActiveRuns added in v1.2.12

func (s *EscalationStore) BulkStopActiveRuns(ctx context.Context, stopStatus string, endedAt time.Time) error

func (*EscalationStore) CountActivePolicies added in v1.2.12

func (s *EscalationStore) CountActivePolicies(ctx context.Context) (int, error)

func (*EscalationStore) DeletePolicy added in v1.2.12

func (s *EscalationStore) DeletePolicy(ctx context.Context, id int64) error

func (*EscalationStore) InsertDelivery added in v1.2.12

func (s *EscalationStore) InsertDelivery(ctx context.Context, d *escalation.Delivery) (int64, error)

InsertDelivery reserves a delivery slot. Returns escalation.ErrDeliveryDuplicate when (run_id, level_index, channel_id) already exists — the caller treats this as "already attempted" (R4 reserve-then-deliver idempotence).

func (*EscalationStore) InsertPolicy added in v1.2.12

func (s *EscalationStore) InsertPolicy(ctx context.Context, p *escalation.Policy) (int64, error)

func (*EscalationStore) InsertRun added in v1.2.12

func (s *EscalationStore) InsertRun(ctx context.Context, r *escalation.Run) (int64, error)

InsertRun persists a new escalation run.

func (*EscalationStore) PauseRunForMaintenance added in v1.2.12

func (s *EscalationStore) PauseRunForMaintenance(ctx context.Context, runID int64, recheckAt time.Time) error

PauseRunForMaintenance moves an active run to paused_by_maintenance and schedules a recheck. Returning to active happens via ResumeRunFromMaintenance.

func (*EscalationStore) PurgeRunsAndDeliveriesOlderThan added in v1.2.12

func (s *EscalationStore) PurgeRunsAndDeliveriesOlderThan(ctx context.Context, before time.Time) error

PurgeRunsAndDeliveriesOlderThan deletes terminated runs (ended_at < before) in batches of 1000. Cascade delete handles escalation_deliveries automatically.

func (*EscalationStore) ResumeRunFromMaintenance added in v1.2.12

func (s *EscalationStore) ResumeRunFromMaintenance(ctx context.Context, runID int64, nextActionAt time.Time) error

ResumeRunFromMaintenance flips a paused run back to active with an updated due time.

func (*EscalationStore) SelectActiveRunsByAlert added in v1.2.12

func (s *EscalationStore) SelectActiveRunsByAlert(ctx context.Context, alertID int64) ([]*escalation.Run, error)

SelectActiveRunsByAlert returns runs in non-terminal state for a given alert. Used by ack/resolve hooks and OnAlertCreated dedup.

func (*EscalationStore) SelectDueRuns added in v1.2.12

func (s *EscalationStore) SelectDueRuns(ctx context.Context, now time.Time) ([]*escalation.Run, error)

SelectDueRuns returns runs in status 'active' or 'paused_by_maintenance' whose next_action_at is at or before now. The partial index covers the active case; paused runs fall back to a small-table scan (acceptable: <200 paused runs per spec hypothesis v1).

func (*EscalationStore) SelectOrphanPendingDeliveries added in v1.2.12

func (s *EscalationStore) SelectOrphanPendingDeliveries(ctx context.Context, before time.Time) ([]*escalation.Delivery, error)

SelectOrphanPendingDeliveries returns deliveries stuck in 'pending' for longer than the runner's orphan timeout. The runner decides whether to retry or abandon.

func (*EscalationStore) SelectPolicies added in v1.2.12

func (s *EscalationStore) SelectPolicies(ctx context.Context, activeOnly bool) ([]*escalation.Policy, error)

func (*EscalationStore) SelectPolicy added in v1.2.12

func (s *EscalationStore) SelectPolicy(ctx context.Context, id int64) (*escalation.Policy, error)

func (*EscalationStore) SelectRun added in v1.2.12

func (s *EscalationStore) SelectRun(ctx context.Context, id int64) (*escalation.Run, error)

func (*EscalationStore) SelectRunDeliveries added in v1.2.12

func (s *EscalationStore) SelectRunDeliveries(ctx context.Context, runID int64) ([]*escalation.Delivery, error)

func (*EscalationStore) SelectRunsByAlert added in v1.2.12

func (s *EscalationStore) SelectRunsByAlert(ctx context.Context, alertID int64) ([]*escalation.Run, error)

func (*EscalationStore) SelectRunsByPolicy added in v1.2.12

func (s *EscalationStore) SelectRunsByPolicy(ctx context.Context, policyID int64, limit int, cursor int64) ([]*escalation.Run, error)

func (*EscalationStore) TerminateRun added in v1.2.12

func (s *EscalationStore) TerminateRun(ctx context.Context, runID int64, status string, endedAt time.Time) error

TerminateRun moves a run to a terminal status (stopped_by_*, exhausted) and stamps ended_at.

func (*EscalationStore) UpdateDelivery added in v1.2.12

func (s *EscalationStore) UpdateDelivery(ctx context.Context, d *escalation.Delivery) error

UpdateDelivery persists status/error/sent_at after a send attempt completes.

func (*EscalationStore) UpdatePolicy added in v1.2.12

func (s *EscalationStore) UpdatePolicy(ctx context.Context, p *escalation.Policy) error

func (*EscalationStore) UpdateRunProgress added in v1.2.12

func (s *EscalationStore) UpdateRunProgress(ctx context.Context, runID int64, lastExecutedLevelIndex int, nextActionAt *time.Time, status string) error

UpdateRunProgress advances a run's level cursor and reschedules its next action. Used by the runner after executing a level (R4 reserve-then-deliver).

type HeartbeatStore

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

HeartbeatStore implements heartbeat.HeartbeatStore using SQLite.

func NewHeartbeatStore

func NewHeartbeatStore(d *DB) *HeartbeatStore

NewHeartbeatStore creates a new SQLite-backed heartbeat store.

func (*HeartbeatStore) CountActiveHeartbeats

func (s *HeartbeatStore) CountActiveHeartbeats(ctx context.Context) (int, error)

func (*HeartbeatStore) CountConfigured added in v1.2.7

func (s *HeartbeatStore) CountConfigured(ctx context.Context) (int, error)

CountConfigured satisfies the telemetry counter interface uniformly across stores. Paused heartbeats keep active=1; active=0 is delete-pending. See specs/015-shm-telemetry.

func (*HeartbeatStore) CreateHeartbeat

func (s *HeartbeatStore) CreateHeartbeat(ctx context.Context, h *heartbeat.Heartbeat) (int64, error)

func (*HeartbeatStore) DeleteExecutionsBefore

func (s *HeartbeatStore) DeleteExecutionsBefore(ctx context.Context, before time.Time, batchSize int) (int64, error)

func (*HeartbeatStore) DeleteHeartbeat

func (s *HeartbeatStore) DeleteHeartbeat(ctx context.Context, id int64) error

func (*HeartbeatStore) DeletePingsBefore

func (s *HeartbeatStore) DeletePingsBefore(ctx context.Context, before time.Time, batchSize int) (int64, error)

func (*HeartbeatStore) GetCurrentExecution

func (s *HeartbeatStore) GetCurrentExecution(ctx context.Context, heartbeatID int64) (*heartbeat.HeartbeatExecution, error)

func (*HeartbeatStore) GetHeartbeatByID

func (s *HeartbeatStore) GetHeartbeatByID(ctx context.Context, id int64) (*heartbeat.Heartbeat, error)

func (*HeartbeatStore) GetHeartbeatByUUID

func (s *HeartbeatStore) GetHeartbeatByUUID(ctx context.Context, uuid string) (*heartbeat.Heartbeat, error)

func (*HeartbeatStore) InsertExecution

func (s *HeartbeatStore) InsertExecution(ctx context.Context, e *heartbeat.HeartbeatExecution) (int64, error)

func (*HeartbeatStore) InsertPing

func (s *HeartbeatStore) InsertPing(ctx context.Context, p *heartbeat.HeartbeatPing) (int64, error)

func (*HeartbeatStore) ListExecutions

func (s *HeartbeatStore) ListExecutions(ctx context.Context, heartbeatID int64, opts heartbeat.ListExecutionsOpts) ([]*heartbeat.HeartbeatExecution, int, error)

func (*HeartbeatStore) ListHeartbeats

func (*HeartbeatStore) ListOverdueHeartbeats

func (s *HeartbeatStore) ListOverdueHeartbeats(ctx context.Context, now time.Time) ([]*heartbeat.Heartbeat, error)

func (*HeartbeatStore) ListPings

func (s *HeartbeatStore) ListPings(ctx context.Context, heartbeatID int64, opts heartbeat.ListPingsOpts) ([]*heartbeat.HeartbeatPing, int, error)

func (*HeartbeatStore) PauseHeartbeat

func (s *HeartbeatStore) PauseHeartbeat(ctx context.Context, id int64) error

func (*HeartbeatStore) ResumeHeartbeat

func (s *HeartbeatStore) ResumeHeartbeat(ctx context.Context, id int64, nextDeadlineAt time.Time) error

func (*HeartbeatStore) UpdateExecution

func (s *HeartbeatStore) UpdateExecution(ctx context.Context, id int64, completedAt *time.Time, durationMs *int64, exitCode *int, outcome heartbeat.ExecutionOutcome, payload *string) error

func (*HeartbeatStore) UpdateHeartbeat

func (s *HeartbeatStore) UpdateHeartbeat(ctx context.Context, id int64, input heartbeat.UpdateHeartbeatInput) error

func (*HeartbeatStore) UpdateHeartbeatState

func (s *HeartbeatStore) UpdateHeartbeatState(ctx context.Context, id int64,
	status heartbeat.HeartbeatStatus, alertState heartbeat.AlertState,
	lastPingAt *time.Time, nextDeadlineAt *time.Time, currentRunStartedAt *time.Time,
	lastExitCode *int, lastDurationMs *int64,
	consecutiveFailures, consecutiveSuccesses int) error

type IncidentStoreImpl

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

IncidentStoreImpl implements status.IncidentStore using SQLite.

func NewIncidentStore

func NewIncidentStore(d *DB) *IncidentStoreImpl

NewIncidentStore creates a new SQLite-backed incident store.

func (*IncidentStoreImpl) CreateIncident

func (s *IncidentStoreImpl) CreateIncident(ctx context.Context, inc *status.Incident, componentIDs []int64, initialMessage string) (int64, error)

func (*IncidentStoreImpl) CreateUpdate

func (s *IncidentStoreImpl) CreateUpdate(ctx context.Context, u *status.IncidentUpdate) (int64, error)

func (*IncidentStoreImpl) DeleteIncident

func (s *IncidentStoreImpl) DeleteIncident(ctx context.Context, id int64) error

func (*IncidentStoreImpl) DeleteIncidentsOlderThan

func (s *IncidentStoreImpl) DeleteIncidentsOlderThan(ctx context.Context, days int) (int64, error)

func (*IncidentStoreImpl) GetActiveIncidentByComponent

func (s *IncidentStoreImpl) GetActiveIncidentByComponent(ctx context.Context, componentID int64) (*status.Incident, error)

func (*IncidentStoreImpl) GetIncident

func (s *IncidentStoreImpl) GetIncident(ctx context.Context, id int64) (*status.Incident, error)

func (*IncidentStoreImpl) ListActiveIncidents

func (s *IncidentStoreImpl) ListActiveIncidents(ctx context.Context) ([]status.Incident, error)

func (*IncidentStoreImpl) ListIncidents

func (s *IncidentStoreImpl) ListIncidents(ctx context.Context, opts status.ListIncidentsOpts) ([]status.Incident, int, error)

func (*IncidentStoreImpl) ListRecentIncidents

func (s *IncidentStoreImpl) ListRecentIncidents(ctx context.Context, days int) ([]status.Incident, error)

func (*IncidentStoreImpl) ListUpdates

func (s *IncidentStoreImpl) ListUpdates(ctx context.Context, incidentID int64) ([]status.IncidentUpdate, error)

func (*IncidentStoreImpl) UpdateIncident

func (s *IncidentStoreImpl) UpdateIncident(ctx context.Context, inc *status.Incident, componentIDs []int64) error

type MCPOAuthStoreImpl

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

MCPOAuthStoreImpl implements oauth.MCPOAuthStore using SQLite.

func NewMCPOAuthStore

func NewMCPOAuthStore(d *DB) *MCPOAuthStoreImpl

NewMCPOAuthStore creates a new SQLite-backed MCP OAuth store.

func (*MCPOAuthStoreImpl) ConsumeCode

func (s *MCPOAuthStoreImpl) ConsumeCode(ctx context.Context, codeHash string) (*oauth.MCPAuthCode, error)

func (*MCPOAuthStoreImpl) DeleteExpired

func (s *MCPOAuthStoreImpl) DeleteExpired(ctx context.Context) (int64, error)

func (*MCPOAuthStoreImpl) GetToken

func (s *MCPOAuthStoreImpl) GetToken(ctx context.Context, tokenHash string) (*oauth.MCPOAuthToken, error)

func (*MCPOAuthStoreImpl) RevokeFamily

func (s *MCPOAuthStoreImpl) RevokeFamily(ctx context.Context, familyID string) error

func (*MCPOAuthStoreImpl) RevokeToken

func (s *MCPOAuthStoreImpl) RevokeToken(ctx context.Context, tokenHash string) error

func (*MCPOAuthStoreImpl) StoreCode

func (s *MCPOAuthStoreImpl) StoreCode(ctx context.Context, code *oauth.MCPAuthCode) error

func (*MCPOAuthStoreImpl) StoreToken

func (s *MCPOAuthStoreImpl) StoreToken(ctx context.Context, token *oauth.MCPOAuthToken) error

type MaintenanceStoreImpl

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

MaintenanceStoreImpl implements status.MaintenanceStore using SQLite.

func NewMaintenanceStore

func NewMaintenanceStore(d *DB) *MaintenanceStoreImpl

NewMaintenanceStore creates a new SQLite-backed maintenance store.

func (*MaintenanceStoreImpl) CreateMaintenance

func (s *MaintenanceStoreImpl) CreateMaintenance(ctx context.Context, mw *status.MaintenanceWindow, componentIDs []int64) (int64, error)

func (*MaintenanceStoreImpl) DeleteMaintenance

func (s *MaintenanceStoreImpl) DeleteMaintenance(ctx context.Context, id int64) error

func (*MaintenanceStoreImpl) GetMaintenance

func (s *MaintenanceStoreImpl) GetMaintenance(ctx context.Context, id int64) (*status.MaintenanceWindow, error)

func (*MaintenanceStoreImpl) GetPendingActivation

func (s *MaintenanceStoreImpl) GetPendingActivation(ctx context.Context, now int64) ([]status.MaintenanceWindow, error)

func (*MaintenanceStoreImpl) GetPendingDeactivation

func (s *MaintenanceStoreImpl) GetPendingDeactivation(ctx context.Context, now int64) ([]status.MaintenanceWindow, error)

func (*MaintenanceStoreImpl) IsEntitySuppressed added in v1.2.12

func (s *MaintenanceStoreImpl) IsEntitySuppressed(
	ctx context.Context, monitorType string, monitorID int64, now time.Time,
) (matched bool, windowID int64, endsAt time.Time, err error)

IsEntitySuppressed returns true (with the matching window ID and end time) if at least one active maintenance window currently covers the given monitor. Active means starts_at ≤ now < ends_at regardless of the window's `active` flag (which controls Status Page display, not suppressor logic).

func (*MaintenanceStoreImpl) ListMaintenance

func (s *MaintenanceStoreImpl) ListMaintenance(ctx context.Context, statusFilter string, limit int) ([]status.MaintenanceWindow, error)

func (*MaintenanceStoreImpl) SetActive

func (s *MaintenanceStoreImpl) SetActive(ctx context.Context, id int64, active bool, incidentID *int64) error

func (*MaintenanceStoreImpl) UpdateMaintenance

func (s *MaintenanceStoreImpl) UpdateMaintenance(ctx context.Context, mw *status.MaintenanceWindow, componentIDs []int64) error

type PersonalizationStoreImpl added in v1.2.11

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

func NewPersonalizationStore added in v1.2.11

func NewPersonalizationStore(d *DB) *PersonalizationStoreImpl

func (*PersonalizationStoreImpl) BumpVersion added in v1.2.11

func (s *PersonalizationStoreImpl) BumpVersion(ctx context.Context) error

func (*PersonalizationStoreImpl) CreateFAQItem added in v1.2.11

func (s *PersonalizationStoreImpl) CreateFAQItem(ctx context.Context, question, answerMD, answerHTML string) (status.FAQItem, error)
func (s *PersonalizationStoreImpl) CreateFooterLink(ctx context.Context, label, url string) (status.FooterLink, error)

func (*PersonalizationStoreImpl) DeleteAsset added in v1.2.11

func (s *PersonalizationStoreImpl) DeleteAsset(ctx context.Context, role status.AssetRole) error

func (*PersonalizationStoreImpl) DeleteFAQItem added in v1.2.11

func (s *PersonalizationStoreImpl) DeleteFAQItem(ctx context.Context, id int64) error
func (s *PersonalizationStoreImpl) DeleteFooterLink(ctx context.Context, id int64) error

func (*PersonalizationStoreImpl) GetAsset added in v1.2.11

func (*PersonalizationStoreImpl) GetSettings added in v1.2.11

func (*PersonalizationStoreImpl) ListFAQItems added in v1.2.11

func (s *PersonalizationStoreImpl) ListFAQItems(ctx context.Context) ([]status.FAQItem, error)
func (s *PersonalizationStoreImpl) ListFooterLinks(ctx context.Context) ([]status.FooterLink, error)

func (*PersonalizationStoreImpl) PutAsset added in v1.2.11

func (*PersonalizationStoreImpl) ReorderFAQItems added in v1.2.11

func (s *PersonalizationStoreImpl) ReorderFAQItems(ctx context.Context, ids []int64) ([]status.FAQItem, error)
func (s *PersonalizationStoreImpl) ReorderFooterLinks(ctx context.Context, ids []int64) ([]status.FooterLink, error)

func (*PersonalizationStoreImpl) UpdateFAQItem added in v1.2.11

func (s *PersonalizationStoreImpl) UpdateFAQItem(ctx context.Context, id int64, question, answerMD, answerHTML string) (status.FAQItem, error)
func (s *PersonalizationStoreImpl) UpdateFooterLink(ctx context.Context, id int64, label, url string) (status.FooterLink, error)

func (*PersonalizationStoreImpl) UpdateSettings added in v1.2.11

type ResourceStore

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

ResourceStore implements resource.ResourceStore using SQLite.

func NewResourceStore

func NewResourceStore(d *DB) *ResourceStore

NewResourceStore creates a new SQLite-backed resource store.

func (*ResourceStore) AggregateDailyRollup

func (s *ResourceStore) AggregateDailyRollup(ctx context.Context, bucketStart, bucketEnd time.Time) error

func (*ResourceStore) AggregateHourlyRollup

func (s *ResourceStore) AggregateHourlyRollup(ctx context.Context, bucketStart, bucketEnd time.Time) error

func (*ResourceStore) DeleteDailyBefore

func (s *ResourceStore) DeleteDailyBefore(ctx context.Context, before time.Time, batchSize int) (int64, error)

func (*ResourceStore) DeleteHourlyBefore

func (s *ResourceStore) DeleteHourlyBefore(ctx context.Context, before time.Time, batchSize int) (int64, error)

func (*ResourceStore) DeleteSnapshotsBefore

func (s *ResourceStore) DeleteSnapshotsBefore(ctx context.Context, before time.Time, batchSize int) (int64, error)

func (*ResourceStore) GetAlertConfig

func (s *ResourceStore) GetAlertConfig(ctx context.Context, containerID int64) (*resource.ResourceAlertConfig, error)

func (*ResourceStore) GetLatestSnapshot

func (s *ResourceStore) GetLatestSnapshot(ctx context.Context, containerID int64) (*resource.ResourceSnapshot, error)

func (*ResourceStore) GetTopConsumersByPeriod

func (s *ResourceStore) GetTopConsumersByPeriod(ctx context.Context, metric string, period string, limit int) ([]resource.TopConsumerRow, error)

func (*ResourceStore) InsertDailyRollup

func (s *ResourceStore) InsertDailyRollup(ctx context.Context, r *resource.RollupRow) error

func (*ResourceStore) InsertHourlyRollup

func (s *ResourceStore) InsertHourlyRollup(ctx context.Context, r *resource.RollupRow) error

func (*ResourceStore) InsertSnapshot

func (s *ResourceStore) InsertSnapshot(ctx context.Context, snap *resource.ResourceSnapshot) (int64, error)

func (*ResourceStore) ListSnapshots

func (s *ResourceStore) ListSnapshots(ctx context.Context, containerID int64, from, to time.Time) ([]*resource.ResourceSnapshot, error)

func (*ResourceStore) ListSnapshotsAggregated

func (s *ResourceStore) ListSnapshotsAggregated(ctx context.Context, containerID int64, from, to time.Time, granularity resource.Granularity) ([]*resource.ResourceSnapshot, error)

func (*ResourceStore) UpsertAlertConfig

func (s *ResourceStore) UpsertAlertConfig(ctx context.Context, cfg *resource.ResourceAlertConfig) error

type RetentionOpts

type RetentionOpts struct {
	EndpointStore    *EndpointStore
	HeartbeatStore   *HeartbeatStore
	CertificateStore *CertificateStore
	ResourceStore    *ResourceStore
}

RetentionOpts holds optional stores for retention cleanup.

type SilenceStoreImpl

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

SilenceStoreImpl implements alert.SilenceStore using SQLite.

func NewSilenceStore

func NewSilenceStore(d *DB) *SilenceStoreImpl

NewSilenceStore creates a new SQLite-backed silence store.

func (*SilenceStoreImpl) CancelSilenceRule

func (s *SilenceStoreImpl) CancelSilenceRule(ctx context.Context, id int64) error

func (*SilenceStoreImpl) GetActiveSilenceRules

func (s *SilenceStoreImpl) GetActiveSilenceRules(ctx context.Context) ([]*alert.SilenceRule, error)

func (*SilenceStoreImpl) InsertSilenceRule

func (s *SilenceStoreImpl) InsertSilenceRule(ctx context.Context, rule *alert.SilenceRule) (int64, error)

func (*SilenceStoreImpl) ListSilenceRules

func (s *SilenceStoreImpl) ListSilenceRules(ctx context.Context, activeOnly bool) ([]*alert.SilenceRule, error)

type StatusComponentStoreImpl

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

StatusComponentStoreImpl implements status.ComponentStore using SQLite.

func NewStatusComponentStore

func NewStatusComponentStore(d *DB) *StatusComponentStoreImpl

NewStatusComponentStore creates a new SQLite-backed component store.

func (*StatusComponentStoreImpl) CountConfigured added in v1.2.7

func (s *StatusComponentStoreImpl) CountConfigured(ctx context.Context) (int, error)

CountConfigured returns the number of operator-configured status-page components. The table uses hard-delete only, so no soft-delete filter is needed. Used by the telemetry subsystem; see specs/015-shm-telemetry.

func (*StatusComponentStoreImpl) CreateComponent

func (s *StatusComponentStoreImpl) CreateComponent(ctx context.Context, c *status.Component) (int64, error)

func (*StatusComponentStoreImpl) DeleteComponent

func (s *StatusComponentStoreImpl) DeleteComponent(ctx context.Context, id int64) error

func (*StatusComponentStoreImpl) GetComponent

func (s *StatusComponentStoreImpl) GetComponent(ctx context.Context, id int64) (*status.Component, error)

func (*StatusComponentStoreImpl) ListComponents

func (s *StatusComponentStoreImpl) ListComponents(ctx context.Context) ([]status.Component, error)

func (*StatusComponentStoreImpl) ListComponentsByMonitor added in v1.2.11

func (s *StatusComponentStoreImpl) ListComponentsByMonitor(ctx context.Context, monitorType string, monitorID int64) ([]status.Component, error)

func (*StatusComponentStoreImpl) ListVisibleComponents

func (s *StatusComponentStoreImpl) ListVisibleComponents(ctx context.Context) ([]status.Component, error)

func (*StatusComponentStoreImpl) RemoveDanglingMonitorRefs added in v1.2.11

func (s *StatusComponentStoreImpl) RemoveDanglingMonitorRefs(ctx context.Context, monitorType string, monitorID int64) error

func (*StatusComponentStoreImpl) UpdateComponent

func (s *StatusComponentStoreImpl) UpdateComponent(ctx context.Context, c *status.Component) error

type SubscriberStoreImpl

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

SubscriberStoreImpl implements status.SubscriberStore using SQLite.

func NewSubscriberStore

func NewSubscriberStore(d *DB) *SubscriberStoreImpl

NewSubscriberStore creates a new SQLite-backed subscriber store.

func (*SubscriberStoreImpl) CleanExpiredUnconfirmed

func (s *SubscriberStoreImpl) CleanExpiredUnconfirmed(ctx context.Context) (int64, error)

func (*SubscriberStoreImpl) ConfirmSubscriber

func (s *SubscriberStoreImpl) ConfirmSubscriber(ctx context.Context, id int64) error

func (*SubscriberStoreImpl) CreateSubscriber

func (s *SubscriberStoreImpl) CreateSubscriber(ctx context.Context, sub *status.StatusSubscriber) (int64, error)

func (*SubscriberStoreImpl) DeleteSubscriber

func (s *SubscriberStoreImpl) DeleteSubscriber(ctx context.Context, id int64) error

func (*SubscriberStoreImpl) GetSubscriberByToken

func (s *SubscriberStoreImpl) GetSubscriberByToken(ctx context.Context, confirmToken string) (*status.StatusSubscriber, error)

func (*SubscriberStoreImpl) GetSubscriberByUnsubToken

func (s *SubscriberStoreImpl) GetSubscriberByUnsubToken(ctx context.Context, unsubToken string) (*status.StatusSubscriber, error)

func (*SubscriberStoreImpl) GetSubscriberStats

func (s *SubscriberStoreImpl) GetSubscriberStats(ctx context.Context) (*status.SubscriberStats, error)

func (*SubscriberStoreImpl) ListConfirmedSubscribers

func (s *SubscriberStoreImpl) ListConfirmedSubscribers(ctx context.Context) ([]status.StatusSubscriber, error)

func (*SubscriberStoreImpl) ListSubscribers

func (s *SubscriberStoreImpl) ListSubscribers(ctx context.Context) ([]status.StatusSubscriber, error)

type SwarmNodeStore added in v1.2.0

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

SwarmNodeStore implements swarm node persistence using SQLite.

func NewSwarmNodeStore added in v1.2.0

func NewSwarmNodeStore(d *DB) *SwarmNodeStore

NewSwarmNodeStore creates a new SQLite-backed swarm node store.

func (*SwarmNodeStore) GetNodeByNodeID added in v1.2.0

func (s *SwarmNodeStore) GetNodeByNodeID(ctx context.Context, nodeID string) (*swarm.SwarmNode, error)

GetNodeByNodeID returns a single swarm node by its Docker node ID.

func (*SwarmNodeStore) ListNodes added in v1.2.0

func (s *SwarmNodeStore) ListNodes(ctx context.Context) ([]*swarm.SwarmNode, error)

ListNodes returns all swarm nodes.

func (*SwarmNodeStore) UpdateNodeStatus added in v1.2.0

func (s *SwarmNodeStore) UpdateNodeStatus(ctx context.Context, nodeID, status, availability string) error

UpdateNodeStatus updates the status and availability of a swarm node.

func (*SwarmNodeStore) UpdateNodeTaskCount added in v1.2.0

func (s *SwarmNodeStore) UpdateNodeTaskCount(ctx context.Context, nodeID string, count int) error

UpdateNodeTaskCount updates the task count for a swarm node.

func (*SwarmNodeStore) UpsertNode added in v1.2.0

func (s *SwarmNodeStore) UpsertNode(ctx context.Context, node *swarm.SwarmNode) error

UpsertNode inserts or updates a swarm node by node_id.

type TriggerStoreImpl added in v1.2.12

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

TriggerStoreImpl implements alert.TriggerStore using SQLite.

func NewTriggerStore added in v1.2.12

func NewTriggerStore(d *DB) *TriggerStoreImpl

NewTriggerStore creates a new SQLite-backed trigger store.

func (*TriggerStoreImpl) DeleteTrigger added in v1.2.12

func (s *TriggerStoreImpl) DeleteTrigger(ctx context.Context, id int64) error

func (*TriggerStoreImpl) GetTrigger added in v1.2.12

func (s *TriggerStoreImpl) GetTrigger(ctx context.Context, id int64) (*alert.AlertTrigger, error)

func (*TriggerStoreImpl) InsertTrigger added in v1.2.12

func (s *TriggerStoreImpl) InsertTrigger(ctx context.Context, t *alert.AlertTrigger) (int64, error)

func (*TriggerStoreImpl) ListChannelsForTrigger added in v1.2.12

func (s *TriggerStoreImpl) ListChannelsForTrigger(ctx context.Context, triggerID int64) ([]int64, error)

func (*TriggerStoreImpl) ListEnabledTriggers added in v1.2.12

func (s *TriggerStoreImpl) ListEnabledTriggers(ctx context.Context) ([]*alert.AlertTrigger, error)

func (*TriggerStoreImpl) ListTriggers added in v1.2.12

func (s *TriggerStoreImpl) ListTriggers(ctx context.Context) ([]*alert.AlertTrigger, error)

func (*TriggerStoreImpl) ListTriggersForChannel added in v1.2.12

func (s *TriggerStoreImpl) ListTriggersForChannel(ctx context.Context, channelID int64) ([]*alert.AlertTrigger, error)

func (*TriggerStoreImpl) SetChannels added in v1.2.12

func (s *TriggerStoreImpl) SetChannels(ctx context.Context, triggerID int64, channelIDs []int64) error

SetChannels replaces all channel links for a trigger atomically (within the writer's serialization guarantee).

func (*TriggerStoreImpl) UpdateTrigger added in v1.2.12

func (s *TriggerStoreImpl) UpdateTrigger(ctx context.Context, t *alert.AlertTrigger) error

type UpdateStore

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

UpdateStore implements update.UpdateStore using SQLite.

func NewUpdateStore

func NewUpdateStore(d *DB) *UpdateStore

NewUpdateStore creates a new SQLite-backed update store.

func (*UpdateStore) CleanupExpired

func (s *UpdateStore) CleanupExpired(ctx context.Context, olderThan time.Time) (int64, error)

func (*UpdateStore) DeleteContainerCVEs

func (s *UpdateStore) DeleteContainerCVEs(ctx context.Context, containerID string) error

func (*UpdateStore) DeleteExclusion

func (s *UpdateStore) DeleteExclusion(ctx context.Context, id int64) error

func (*UpdateStore) DeleteImageUpdatesByContainer

func (s *UpdateStore) DeleteImageUpdatesByContainer(ctx context.Context, containerID string) error

func (*UpdateStore) DeleteStaleImageUpdates added in v1.1.0

func (s *UpdateStore) DeleteStaleImageUpdates(ctx context.Context, scanID int64, scannedContainerNames []string) (int64, error)

func (*UpdateStore) DeleteVersionPin

func (s *UpdateStore) DeleteVersionPin(ctx context.Context, containerID string) error

func (*UpdateStore) GetCVECacheEntries

func (s *UpdateStore) GetCVECacheEntries(ctx context.Context, ecosystem, packageName, packageVersion string) ([]*update.CVECacheEntry, error)

func (*UpdateStore) GetCVESummaryCounts

func (s *UpdateStore) GetCVESummaryCounts(ctx context.Context) (map[string]int, error)

func (*UpdateStore) GetDigestBaseline added in v1.1.2

func (s *UpdateStore) GetDigestBaseline(ctx context.Context, containerID string) (*update.DigestBaseline, error)

GetDigestBaseline returns the stored digest baseline for a container.

func (*UpdateStore) GetImageUpdate

func (s *UpdateStore) GetImageUpdate(ctx context.Context, id int64) (*update.ImageUpdate, error)

func (*UpdateStore) GetImageUpdateByContainer

func (s *UpdateStore) GetImageUpdateByContainer(ctx context.Context, containerID string) (*update.ImageUpdate, error)

func (*UpdateStore) GetLatestScanRecord

func (s *UpdateStore) GetLatestScanRecord(ctx context.Context) (*update.ScanRecord, error)

func (*UpdateStore) GetScanRecord

func (s *UpdateStore) GetScanRecord(ctx context.Context, id int64) (*update.ScanRecord, error)

func (*UpdateStore) GetUpdateSummary

func (s *UpdateStore) GetUpdateSummary(ctx context.Context) (*update.UpdateSummary, error)

func (*UpdateStore) GetVersionPin

func (s *UpdateStore) GetVersionPin(ctx context.Context, containerID string) (*update.VersionPin, error)

func (*UpdateStore) InsertCVECacheEntry

func (s *UpdateStore) InsertCVECacheEntry(ctx context.Context, e *update.CVECacheEntry) (int64, error)

func (*UpdateStore) InsertExclusion

func (s *UpdateStore) InsertExclusion(ctx context.Context, e *update.UpdateExclusion) (int64, error)

func (*UpdateStore) InsertImageUpdate

func (s *UpdateStore) InsertImageUpdate(ctx context.Context, u *update.ImageUpdate) (int64, error)

func (*UpdateStore) InsertRiskScoreRecord

func (s *UpdateStore) InsertRiskScoreRecord(ctx context.Context, r *update.RiskScoreRecord) (int64, error)

func (*UpdateStore) InsertScanRecord

func (s *UpdateStore) InsertScanRecord(ctx context.Context, r *update.ScanRecord) (int64, error)

func (*UpdateStore) InsertVersionPin

func (s *UpdateStore) InsertVersionPin(ctx context.Context, p *update.VersionPin) (int64, error)

func (*UpdateStore) IsCVECacheFresh

func (s *UpdateStore) IsCVECacheFresh(ctx context.Context, ecosystem, packageName, packageVersion string) (bool, error)

func (*UpdateStore) ListAllActiveCVEs

func (s *UpdateStore) ListAllActiveCVEs(ctx context.Context, opts update.ListCVEsOpts) ([]*update.ContainerCVE, error)

func (*UpdateStore) ListContainerCVEs

func (s *UpdateStore) ListContainerCVEs(ctx context.Context, containerID string) ([]*update.ContainerCVE, error)

func (*UpdateStore) ListExclusions

func (s *UpdateStore) ListExclusions(ctx context.Context) ([]*update.UpdateExclusion, error)

func (*UpdateStore) ListImageUpdates

func (s *UpdateStore) ListImageUpdates(ctx context.Context, opts update.ListImageUpdatesOpts) ([]*update.ImageUpdate, error)

func (*UpdateStore) ListRiskScoreHistory

func (s *UpdateStore) ListRiskScoreHistory(ctx context.Context, containerID string, from, to time.Time) ([]*update.RiskScoreRecord, error)

func (*UpdateStore) ListStaleImageUpdates added in v1.2.12

func (s *UpdateStore) ListStaleImageUpdates(ctx context.Context, scanID int64, scannedContainerNames []string) ([]string, error)

ListStaleImageUpdates returns the container names that had a pending update before this scan but are no longer in the latest results — i.e. containers that were upgraded between scans. Used to emit recovery alerts.

func (*UpdateStore) ResolveContainerCVE

func (s *UpdateStore) ResolveContainerCVE(ctx context.Context, containerID, cveID string) error

func (*UpdateStore) UpdateImageUpdate

func (s *UpdateStore) UpdateImageUpdate(ctx context.Context, u *update.ImageUpdate) error

func (*UpdateStore) UpdateScanRecord

func (s *UpdateStore) UpdateScanRecord(ctx context.Context, r *update.ScanRecord) error

func (*UpdateStore) UpsertContainerCVE

func (s *UpdateStore) UpsertContainerCVE(ctx context.Context, c *update.ContainerCVE) error

func (*UpdateStore) UpsertDigestBaseline added in v1.1.2

func (s *UpdateStore) UpsertDigestBaseline(ctx context.Context, b *update.DigestBaseline) error

UpsertDigestBaseline inserts or updates the digest baseline for a container.

type UptimeDailyStore

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

UptimeDailyStore provides daily uptime aggregation queries.

func NewUptimeDailyStore

func NewUptimeDailyStore(d *DB) *UptimeDailyStore

NewUptimeDailyStore creates a new daily uptime store.

func (*UptimeDailyStore) GetEndpointDailyUptime

func (s *UptimeDailyStore) GetEndpointDailyUptime(ctx context.Context, endpointID int64, days int) ([]DailyUptime, error)

GetEndpointDailyUptime aggregates endpoint check results by UTC day. Returns up to `days` days of data, most recent first. Days with no checks have UptimePercent = nil.

func (*UptimeDailyStore) GetHeartbeatDailyUptime

func (s *UptimeDailyStore) GetHeartbeatDailyUptime(ctx context.Context, heartbeatID int64, days int) ([]DailyUptime, error)

GetHeartbeatDailyUptime aggregates heartbeat pings by UTC day. Returns up to `days` days of data, most recent first. Days with no pings have UptimePercent = nil.

type WebhookStoreImpl

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

WebhookStoreImpl implements webhook.WebhookSubscriptionStore using SQLite.

func NewWebhookStore

func NewWebhookStore(d *DB) *WebhookStoreImpl

NewWebhookStore creates a new SQLite-backed webhook subscription store.

func (*WebhookStoreImpl) CountConfigured added in v1.2.7

func (s *WebhookStoreImpl) CountConfigured(ctx context.Context) (int, error)

CountConfigured returns the number of operator-configured webhook subscriptions. is_active=0 means operator-paused (still counted per spec). Used by the telemetry subsystem; see specs/015-shm-telemetry.

func (*WebhookStoreImpl) Create

func (*WebhookStoreImpl) Delete

func (s *WebhookStoreImpl) Delete(ctx context.Context, id string) error

func (*WebhookStoreImpl) GetByID

func (*WebhookStoreImpl) List

func (*WebhookStoreImpl) ListActive

func (*WebhookStoreImpl) UpdateDeliveryStatus

func (s *WebhookStoreImpl) UpdateDeliveryStatus(ctx context.Context, id string, status string, failureCount int) error

type WriteOp

type WriteOp struct {
	Query string
	Args  []interface{}
	Done  chan WriteResult
}

WriteOp represents a single write operation to be serialized.

type WriteResult

type WriteResult struct {
	LastInsertID int64
	RowsAffected int64
	Err          error
}

WriteResult contains the result of a write operation.

type Writer

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

Writer serializes all database writes through a single goroutine.

func NewWriter

func NewWriter(db *sql.DB, logger *slog.Logger) *Writer

NewWriter creates a new serialized writer.

func (*Writer) Exec

func (w *Writer) Exec(ctx context.Context, query string, args ...interface{}) (WriteResult, error)

Exec sends a write operation and waits for the result.

func (*Writer) Start

func (w *Writer) Start(ctx context.Context)

Start begins the single-writer goroutine. Blocks until ctx is cancelled.

Jump to

Keyboard shortcuts

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