postgres

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestDB added in v0.1.2

func NewTestDB(t *testing.T) *pgxpool.Pool

NewTestDB returns a pgxpool.Pool connected to the database specified by POSTGRES_URL. If the variable is not set the test is skipped. All migrations are applied automatically and the pool is closed when the test finishes.

Types

type DB

type DB = sqlc.DBTX

DB is the database interface required by the postgres package. It is satisfied by *pgxpool.Pool.

type EpicRepository

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

EpicRepository implements epic.Repository using PostgreSQL.

func NewEpicRepository

func NewEpicRepository(pool *pgxpool.Pool) *EpicRepository

NewEpicRepository creates a new EpicRepository backed by the given pgx pool.

func (*EpicRepository) AppendSessionLog

func (r *EpicRepository) AppendSessionLog(ctx context.Context, id epic.EpicID, lines []string) error

func (*EpicRepository) ClaimEpic

func (r *EpicRepository) ClaimEpic(ctx context.Context, id epic.EpicID) (bool, error)

func (*EpicRepository) ClearEpicFeedback

func (r *EpicRepository) ClearEpicFeedback(ctx context.Context, id epic.EpicID) error

func (*EpicRepository) CreateEpic

func (r *EpicRepository) CreateEpic(ctx context.Context, e *epic.Epic) error

func (*EpicRepository) DeleteEpic

func (r *EpicRepository) DeleteEpic(ctx context.Context, id epic.EpicID) error

func (*EpicRepository) EpicHeartbeat

func (r *EpicRepository) EpicHeartbeat(ctx context.Context, id epic.EpicID) error

func (*EpicRepository) ListActiveEpics

func (r *EpicRepository) ListActiveEpics(ctx context.Context) ([]*epic.Epic, error)

func (*EpicRepository) ListEpics

func (r *EpicRepository) ListEpics(ctx context.Context) ([]*epic.Epic, error)

func (*EpicRepository) ListEpicsByRepo

func (r *EpicRepository) ListEpicsByRepo(ctx context.Context, repoID string) ([]*epic.Epic, error)

func (*EpicRepository) ListPlanningEpics

func (r *EpicRepository) ListPlanningEpics(ctx context.Context) ([]*epic.Epic, error)

func (*EpicRepository) ListStaleEpics

func (r *EpicRepository) ListStaleEpics(ctx context.Context, threshold time.Time) ([]*epic.Epic, error)

func (*EpicRepository) ReadEpic

func (r *EpicRepository) ReadEpic(ctx context.Context, id epic.EpicID) (*epic.Epic, error)

func (*EpicRepository) ReleaseEpicClaim

func (r *EpicRepository) ReleaseEpicClaim(ctx context.Context, id epic.EpicID) error

func (*EpicRepository) RemoveTaskID

func (r *EpicRepository) RemoveTaskID(ctx context.Context, id epic.EpicID, taskID string) error

func (*EpicRepository) SetEpicFeedback

func (r *EpicRepository) SetEpicFeedback(ctx context.Context, id epic.EpicID, feedback, feedbackType string) error

func (*EpicRepository) SetTaskIDs

func (r *EpicRepository) SetTaskIDs(ctx context.Context, id epic.EpicID, taskIDs []string) error

func (*EpicRepository) UpdateEpic

func (r *EpicRepository) UpdateEpic(ctx context.Context, e *epic.Epic) error

func (*EpicRepository) UpdateEpicStatus

func (r *EpicRepository) UpdateEpicStatus(ctx context.Context, id epic.EpicID, status epic.Status) error

func (*EpicRepository) UpdateProposedTasks

func (r *EpicRepository) UpdateProposedTasks(ctx context.Context, id epic.EpicID, tasks []epic.ProposedTask) error

type EventNotifier

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

EventNotifier implements task.Notifier using PostgreSQL LISTEN/NOTIFY.

func NewEventNotifier

func NewEventNotifier(pool *pgxpool.Pool, logger log.Logger) *EventNotifier

NewEventNotifier creates a new EventNotifier backed by the given pgx pool.

func (*EventNotifier) Listen

func (n *EventNotifier) Listen(ctx context.Context, broker *task.Broker)

Listen blocks and listens for PG notifications on the task_events channel, calling broker.Receive for each event. It reconnects automatically on connection errors.

func (*EventNotifier) Notify

func (n *EventNotifier) Notify(ctx context.Context, payload []byte) error

Notify sends a payload via PG NOTIFY.

type GitHubTokenRepository

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

GitHubTokenRepository implements githubtoken.Repository using PostgreSQL.

func NewGitHubTokenRepository

func NewGitHubTokenRepository(pool *pgxpool.Pool) *GitHubTokenRepository

NewGitHubTokenRepository creates a new GitHubTokenRepository backed by the given pgx pool.

func (*GitHubTokenRepository) DeleteGitHubToken

func (r *GitHubTokenRepository) DeleteGitHubToken(ctx context.Context) error

func (*GitHubTokenRepository) ReadGitHubToken

func (r *GitHubTokenRepository) ReadGitHubToken(ctx context.Context) (string, error)

func (*GitHubTokenRepository) UpsertGitHubToken

func (r *GitHubTokenRepository) UpsertGitHubToken(ctx context.Context, encryptedToken string, now time.Time) error

type RepoRepository

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

RepoRepository implements repo.Repository using PostgreSQL.

func NewRepoRepository

func NewRepoRepository(pool *pgxpool.Pool) *RepoRepository

NewRepoRepository creates a new RepoRepository backed by the given pgx pool.

func (*RepoRepository) CreateRepo

func (r *RepoRepository) CreateRepo(ctx context.Context, rp *repo.Repo) error

func (*RepoRepository) DeleteRepo

func (r *RepoRepository) DeleteRepo(ctx context.Context, id repo.RepoID) error

func (*RepoRepository) ListRepos

func (r *RepoRepository) ListRepos(ctx context.Context) ([]*repo.Repo, error)

func (*RepoRepository) ReadRepo

func (r *RepoRepository) ReadRepo(ctx context.Context, id repo.RepoID) (*repo.Repo, error)

func (*RepoRepository) ReadRepoByFullName

func (r *RepoRepository) ReadRepoByFullName(ctx context.Context, fullName string) (*repo.Repo, error)

type SettingRepository

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

SettingRepository implements setting.Repository using PostgreSQL.

func NewSettingRepository

func NewSettingRepository(pool *pgxpool.Pool) *SettingRepository

NewSettingRepository creates a new SettingRepository backed by the given pgx pool.

func (*SettingRepository) DeleteSetting

func (r *SettingRepository) DeleteSetting(ctx context.Context, key string) error

func (*SettingRepository) ListSettings

func (r *SettingRepository) ListSettings(ctx context.Context) (map[string]string, error)

func (*SettingRepository) ReadSetting

func (r *SettingRepository) ReadSetting(ctx context.Context, key string) (string, error)

func (*SettingRepository) UpsertSetting

func (r *SettingRepository) UpsertSetting(ctx context.Context, key, value string) error

type TaskRepository

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

TaskRepository implements task.Repository using PostgreSQL.

func NewTaskRepository

func NewTaskRepository(pool *pgxpool.Pool) *TaskRepository

NewTaskRepository creates a new TaskRepository backed by the given pgx pool.

func (*TaskRepository) AddCost

func (r *TaskRepository) AddCost(ctx context.Context, id task.TaskID, costUSD float64) error

func (*TaskRepository) AppendTaskLogs

func (r *TaskRepository) AppendTaskLogs(ctx context.Context, id task.TaskID, attempt int, logs []string) error

func (*TaskRepository) BeginTxFunc

func (r *TaskRepository) BeginTxFunc(ctx context.Context, fn func(ctx context.Context, txn tx.Tx, repo task.Repository) error) error

func (*TaskRepository) BulkCloseTasksByEpic

func (r *TaskRepository) BulkCloseTasksByEpic(ctx context.Context, epicID, reason string) error

func (*TaskRepository) BulkDeleteTasksByEpic

func (r *TaskRepository) BulkDeleteTasksByEpic(ctx context.Context, epicID string) error

func (*TaskRepository) BulkDeleteTasksByIDs

func (r *TaskRepository) BulkDeleteTasksByIDs(ctx context.Context, ids []string) error

func (*TaskRepository) ClaimTask

func (r *TaskRepository) ClaimTask(ctx context.Context, id task.TaskID) (bool, error)

func (*TaskRepository) ClearEpicIDForTasks

func (r *TaskRepository) ClearEpicIDForTasks(ctx context.Context, epicID string) error

func (*TaskRepository) CloseTask

func (r *TaskRepository) CloseTask(ctx context.Context, id task.TaskID, reason string) error

func (*TaskRepository) CreateTask

func (r *TaskRepository) CreateTask(ctx context.Context, t *task.Task) error

func (*TaskRepository) DeleteExpiredLogs

func (r *TaskRepository) DeleteExpiredLogs(ctx context.Context, before time.Time) (int64, error)

func (*TaskRepository) DeleteTask

func (r *TaskRepository) DeleteTask(ctx context.Context, id task.TaskID) error

func (*TaskRepository) DeleteTaskLogs

func (r *TaskRepository) DeleteTaskLogs(ctx context.Context, id task.TaskID) error

func (*TaskRepository) FeedbackRetryTask

func (r *TaskRepository) FeedbackRetryTask(ctx context.Context, id task.TaskID, feedback string) (bool, error)

func (*TaskRepository) HasTasksForRepo

func (r *TaskRepository) HasTasksForRepo(ctx context.Context, repoID string) (bool, error)

func (*TaskRepository) Heartbeat

func (r *TaskRepository) Heartbeat(ctx context.Context, id task.TaskID) (bool, error)

func (*TaskRepository) ListPendingTasks

func (r *TaskRepository) ListPendingTasks(ctx context.Context) ([]*task.Task, error)

func (*TaskRepository) ListPendingTasksByRepos

func (r *TaskRepository) ListPendingTasksByRepos(ctx context.Context, repoIDs []string) ([]*task.Task, error)

func (*TaskRepository) ListStaleTasks

func (r *TaskRepository) ListStaleTasks(ctx context.Context, before time.Time) ([]*task.Task, error)

func (*TaskRepository) ListTasks

func (r *TaskRepository) ListTasks(ctx context.Context) ([]*task.Task, error)

func (*TaskRepository) ListTasksByEpic

func (r *TaskRepository) ListTasksByEpic(ctx context.Context, epicID string) ([]*task.Task, error)

func (*TaskRepository) ListTasksByRepo

func (r *TaskRepository) ListTasksByRepo(ctx context.Context, repoID string) ([]*task.Task, error)

func (*TaskRepository) ListTasksInReview

func (r *TaskRepository) ListTasksInReview(ctx context.Context) ([]*task.Task, error)

func (*TaskRepository) ListTasksInReviewByRepo

func (r *TaskRepository) ListTasksInReviewByRepo(ctx context.Context, repoID string) ([]*task.Task, error)

func (*TaskRepository) ListTasksInReviewNoPR

func (r *TaskRepository) ListTasksInReviewNoPR(ctx context.Context) ([]*task.Task, error)

func (*TaskRepository) ManualRetryTask

func (r *TaskRepository) ManualRetryTask(ctx context.Context, id task.TaskID, instructions string) (bool, error)

func (*TaskRepository) ReadTask

func (r *TaskRepository) ReadTask(ctx context.Context, id task.TaskID) (*task.Task, error)

func (*TaskRepository) ReadTaskLogs

func (r *TaskRepository) ReadTaskLogs(ctx context.Context, id task.TaskID) ([]string, error)

func (*TaskRepository) ReadTaskStatus

func (r *TaskRepository) ReadTaskStatus(ctx context.Context, id task.TaskID) (task.Status, error)

func (*TaskRepository) RemoveDependency

func (r *TaskRepository) RemoveDependency(ctx context.Context, id task.TaskID, depID string) error

func (*TaskRepository) RetryTask

func (r *TaskRepository) RetryTask(ctx context.Context, id task.TaskID, reason string) (bool, error)

func (*TaskRepository) ScheduleRetryFromRunning

func (r *TaskRepository) ScheduleRetryFromRunning(ctx context.Context, id task.TaskID, reason string) (bool, error)

func (*TaskRepository) SetAgentStatus

func (r *TaskRepository) SetAgentStatus(ctx context.Context, id task.TaskID, status string) error

func (*TaskRepository) SetBranchName

func (r *TaskRepository) SetBranchName(ctx context.Context, id task.TaskID, branchName string) error

func (*TaskRepository) SetCloseReason

func (r *TaskRepository) SetCloseReason(ctx context.Context, id task.TaskID, reason string) error

func (*TaskRepository) SetConsecutiveFailures

func (r *TaskRepository) SetConsecutiveFailures(ctx context.Context, id task.TaskID, count int) error

func (*TaskRepository) SetReady

func (r *TaskRepository) SetReady(ctx context.Context, id task.TaskID, ready bool) error

func (*TaskRepository) SetRetryContext

func (r *TaskRepository) SetRetryContext(ctx context.Context, id task.TaskID, retryCtx string) error

func (*TaskRepository) SetTaskPullRequest

func (r *TaskRepository) SetTaskPullRequest(ctx context.Context, id task.TaskID, prURL string, prNumber int) error

func (*TaskRepository) StartOverTask

func (r *TaskRepository) StartOverTask(ctx context.Context, id task.TaskID, params task.StartOverTaskParams) (bool, error)

func (*TaskRepository) StopTask

func (r *TaskRepository) StopTask(ctx context.Context, id task.TaskID, reason string) (bool, error)

func (*TaskRepository) StreamTaskLogs

func (r *TaskRepository) StreamTaskLogs(ctx context.Context, id task.TaskID, fn func(attempt int, lines []string) error) error

func (*TaskRepository) TaskExists

func (r *TaskRepository) TaskExists(ctx context.Context, id task.TaskID) (bool, error)

func (*TaskRepository) UpdatePendingTask

func (r *TaskRepository) UpdatePendingTask(ctx context.Context, id task.TaskID, params task.UpdatePendingTaskParams) (bool, error)

func (*TaskRepository) UpdateTaskStatus

func (r *TaskRepository) UpdateTaskStatus(ctx context.Context, id task.TaskID, status task.Status) error

func (*TaskRepository) WithTx

func (r *TaskRepository) WithTx(txn tx.Tx) task.Repository

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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