Help us shape the future of Go! Take the 2026 Go Developer Survey

postgres

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const LocalWorkspaceID = store.LocalWorkspaceID

LocalWorkspaceID is retained for backward compatibility; the canonical constant now lives in the store package.

Variables

This section is empty.

Functions

func ConnectPool

func ConnectPool(ctx context.Context, dsn string) (*pgxpool.Pool, error)

ConnectPool opens a pgxpool connection and pings it.

func RunMigrations

func RunMigrations(pool *pgxpool.Pool) error

func SeedLocalWorkspace

func SeedLocalWorkspace(ctx context.Context, s *Store, dailyCap int) error

SeedLocalWorkspace creates the default local workspace if it doesn't exist. dailyCap is the per-24h request limit (0 = unlimited). Migrations already set this to 200 on existing databases, but fresh boots need the seed to carry the cap in the INSERT payload.

Types

type Store

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

func New

func New(pool *pgxpool.Pool) *Store

func (*Store) BumpSessionCallIndex

func (s *Store) BumpSessionCallIndex(ctx context.Context, sessionID string) (int, error)

BumpSessionCallIndex increments call_index by 1 atomically and returns the PRE-bump value so callers can use it as the step index for the current request without a round-trip + race.

func (*Store) CountRequestsSince added in v1.2.0

func (s *Store) CountRequestsSince(ctx context.Context, workspaceID string, since time.Time) (int, error)

func (*Store) CreateFeedback added in v1.2.0

func (s *Store) CreateFeedback(ctx context.Context, f *store.Feedback) error

func (*Store) CreateRequestLog

func (s *Store) CreateRequestLog(ctx context.Context, l *store.RequestLog) error

func (*Store) CreateScenario

func (s *Store) CreateScenario(ctx context.Context, sc *store.Scenario) error

func (*Store) CreateScenarioRun

func (s *Store) CreateScenarioRun(ctx context.Context, r *store.ScenarioRun) error

func (*Store) CreateSession

func (s *Store) CreateSession(ctx context.Context, sess *store.Session) error

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, u *store.User, passwordHash string) error

func (*Store) CreateWebhookLog

func (s *Store) CreateWebhookLog(ctx context.Context, l *store.WebhookLog) error

func (*Store) CreateWorkspace

func (s *Store) CreateWorkspace(ctx context.Context, w *store.Workspace) error

func (*Store) DeleteScenario

func (s *Store) DeleteScenario(ctx context.Context, id string) error

func (*Store) DeleteSession

func (s *Store) DeleteSession(ctx context.Context, id string) error

func (*Store) GetActiveSession

func (s *Store) GetActiveSession(ctx context.Context, workspaceID string) (*store.Session, error)

func (*Store) GetDefaultScenario

func (s *Store) GetDefaultScenario(ctx context.Context, workspaceID string) (*store.Scenario, error)

func (*Store) GetRequestLog

func (s *Store) GetRequestLog(ctx context.Context, id string) (*store.RequestLog, error)

func (*Store) GetScenario

func (s *Store) GetScenario(ctx context.Context, id string) (*store.Scenario, error)

func (*Store) GetUserByEmail

func (s *Store) GetUserByEmail(ctx context.Context, email string) (*store.User, string, error)

func (*Store) GetUserByID

func (s *Store) GetUserByID(ctx context.Context, id string) (*store.User, error)

func (*Store) GetWebhookLog

func (s *Store) GetWebhookLog(ctx context.Context, id string) (*store.WebhookLog, error)

func (*Store) GetWebhookLogByRequestID

func (s *Store) GetWebhookLogByRequestID(ctx context.Context, requestLogID string) (*store.WebhookLog, error)

func (*Store) GetWorkspaceByAPIKey

func (s *Store) GetWorkspaceByAPIKey(ctx context.Context, apiKey string) (*store.Workspace, error)

func (*Store) GetWorkspaceByID

func (s *Store) GetWorkspaceByID(ctx context.Context, id string) (*store.Workspace, error)

func (*Store) GetWorkspaceBySlug

func (s *Store) GetWorkspaceBySlug(ctx context.Context, slug string) (*store.Workspace, error)

func (*Store) ListRequestLogs

func (s *Store) ListRequestLogs(ctx context.Context, workspaceID string, limit, offset int) ([]*store.RequestLog, error)

func (*Store) ListScenarios

func (s *Store) ListScenarios(ctx context.Context, workspaceID string) ([]*store.Scenario, error)

func (*Store) ListWebhookLogs

func (s *Store) ListWebhookLogs(ctx context.Context, workspaceID string, limit, offset int) ([]*store.WebhookLog, error)

ListWebhookLogs returns webhook logs whose parent request_log belongs to the given workspace. Newest first.

func (*Store) TrimOldLogs added in v1.2.0

func (s *Store) TrimOldLogs(ctx context.Context, cutoff time.Time) (int64, error)

TrimOldLogs deletes request_logs older than cutoff. Webhook rows cascade via request_log_id FK. Returns rows deleted.

func (*Store) UpdateScenario

func (s *Store) UpdateScenario(ctx context.Context, sc *store.Scenario) error

func (*Store) UpdateScenarioRun

func (s *Store) UpdateScenarioRun(ctx context.Context, r *store.ScenarioRun) error

func (*Store) UpdateUserLastLogin

func (s *Store) UpdateUserLastLogin(ctx context.Context, id string, at time.Time) error

func (*Store) UpdateWebhookLog

func (s *Store) UpdateWebhookLog(ctx context.Context, l *store.WebhookLog) error

func (*Store) UpdateWorkspace

func (s *Store) UpdateWorkspace(ctx context.Context, w *store.Workspace) error

UpdateWorkspace persists changes to mutable workspace fields. Currently only WebhookURLs is editable; slug and api_key are immutable after create.

Jump to

Keyboard shortcuts

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