// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: status.sql package postgresdb import ( "context" "time" ) const configSnapshotByID = `-- name: ConfigSnapshotByID :one SELECT schema, document, published_at FROM config_snapshot WHERE id = 1 ` type ConfigSnapshotByIDRow struct { Schema string Document string PublishedAt time.Time } func (q *Queries) ConfigSnapshotByID(ctx context.Context) (ConfigSnapshotByIDRow, error) { row := q.db.QueryRow(ctx, configSnapshotByID) var i ConfigSnapshotByIDRow err := row.Scan(&i.Schema, &i.Document, &i.PublishedAt) return i, err } const deleteChannelStatusNotIn = `-- name: DeleteChannelStatusNotIn :exec DELETE FROM channel_status WHERE NOT (id = ANY($1::text[])) ` func (q *Queries) DeleteChannelStatusNotIn(ctx context.Context, dollar_1 []string) error { _, err := q.db.Exec(ctx, deleteChannelStatusNotIn, dollar_1) return err } const deletePresenceBefore = `-- name: DeletePresenceBefore :exec DELETE FROM presence WHERE reported_at < $1 ` func (q *Queries) DeletePresenceBefore(ctx context.Context, reportedAt time.Time) error { _, err := q.db.Exec(ctx, deletePresenceBefore, reportedAt) return err } const listApplyStatus = `-- name: ListApplyStatus :many SELECT process, kind, applied_version, error, reported_at FROM apply_status ORDER BY process, kind ` func (q *Queries) ListApplyStatus(ctx context.Context) ([]ApplyStatus, error) { rows, err := q.db.Query(ctx, listApplyStatus) if err != nil { return nil, err } defer rows.Close() var items []ApplyStatus for rows.Next() { var i ApplyStatus if err := rows.Scan( &i.Process, &i.Kind, &i.AppliedVersion, &i.Error, &i.ReportedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const listChannelStatus = `-- name: ListChannelStatus :many SELECT id, name, state, detail, configured, reload_supported, observed_at FROM channel_status ORDER BY id ` func (q *Queries) ListChannelStatus(ctx context.Context) ([]ChannelStatus, error) { rows, err := q.db.Query(ctx, listChannelStatus) if err != nil { return nil, err } defer rows.Close() var items []ChannelStatus for rows.Next() { var i ChannelStatus if err := rows.Scan( &i.ID, &i.Name, &i.State, &i.Detail, &i.Configured, &i.ReloadSupported, &i.ObservedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const listPresence = `-- name: ListPresence :many SELECT service, instance_id, version, install_type, started_at, reported_at, ready, detail FROM presence ORDER BY service, instance_id ` func (q *Queries) ListPresence(ctx context.Context) ([]Presence, error) { rows, err := q.db.Query(ctx, listPresence) if err != nil { return nil, err } defer rows.Close() var items []Presence for rows.Next() { var i Presence if err := rows.Scan( &i.Service, &i.InstanceID, &i.Version, &i.InstallType, &i.StartedAt, &i.ReportedAt, &i.Ready, &i.Detail, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const upsertApplyStatus = `-- name: UpsertApplyStatus :exec INSERT INTO apply_status (process, kind, applied_version, error, reported_at) VALUES ($1, $2, $3, $4, $5) ON CONFLICT (process, kind) DO UPDATE SET applied_version = excluded.applied_version, error = excluded.error, reported_at = excluded.reported_at ` type UpsertApplyStatusParams struct { Process string Kind string AppliedVersion int64 Error string ReportedAt time.Time } func (q *Queries) UpsertApplyStatus(ctx context.Context, arg UpsertApplyStatusParams) error { _, err := q.db.Exec(ctx, upsertApplyStatus, arg.Process, arg.Kind, arg.AppliedVersion, arg.Error, arg.ReportedAt, ) return err } const upsertChannelStatus = `-- name: UpsertChannelStatus :exec INSERT INTO channel_status (id, name, state, detail, configured, reload_supported, observed_at) VALUES ($1, $2, $3, $4, $5, $6, $7) ON CONFLICT (id) DO UPDATE SET name = excluded.name, state = excluded.state, detail = excluded.detail, configured = excluded.configured, reload_supported = excluded.reload_supported, observed_at = excluded.observed_at ` type UpsertChannelStatusParams struct { ID string Name string State string Detail string Configured bool ReloadSupported bool ObservedAt time.Time } func (q *Queries) UpsertChannelStatus(ctx context.Context, arg UpsertChannelStatusParams) error { _, err := q.db.Exec(ctx, upsertChannelStatus, arg.ID, arg.Name, arg.State, arg.Detail, arg.Configured, arg.ReloadSupported, arg.ObservedAt, ) return err } const upsertConfigSnapshot = `-- name: UpsertConfigSnapshot :exec INSERT INTO config_snapshot (id, schema, document, published_at) VALUES (1, $1, $2, $3) ON CONFLICT (id) DO UPDATE SET schema = excluded.schema, document = excluded.document, published_at = excluded.published_at ` type UpsertConfigSnapshotParams struct { Schema string Document string PublishedAt time.Time } // Status projection queries: the published configuration snapshot and the // channel / apply-status runtime reports the UI reads across the State Store // boundary. func (q *Queries) UpsertConfigSnapshot(ctx context.Context, arg UpsertConfigSnapshotParams) error { _, err := q.db.Exec(ctx, upsertConfigSnapshot, arg.Schema, arg.Document, arg.PublishedAt) return err } const upsertPresence = `-- name: UpsertPresence :exec INSERT INTO presence (service, instance_id, version, install_type, started_at, reported_at, ready, detail) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT (service, instance_id) DO UPDATE SET version = excluded.version, install_type = excluded.install_type, started_at = excluded.started_at, reported_at = excluded.reported_at, ready = excluded.ready, detail = excluded.detail ` type UpsertPresenceParams struct { Service string InstanceID string Version string InstallType string StartedAt time.Time ReportedAt time.Time Ready bool Detail string } func (q *Queries) UpsertPresence(ctx context.Context, arg UpsertPresenceParams) error { _, err := q.db.Exec(ctx, upsertPresence, arg.Service, arg.InstanceID, arg.Version, arg.InstallType, arg.StartedAt, arg.ReportedAt, arg.Ready, arg.Detail, ) return err }