postgres

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPostgresTaskRepository

func NewPostgresTaskRepository(pool *pgxpool.Pool) port.TaskRepository

Types

type CreateTaskParams

type CreateTaskParams struct {
	ID             pgtype.UUID
	ClientID       string
	TaskType       string
	Payload        []byte
	State          string
	RunAt          pgtype.Timestamptz
	WorkerID       pgtype.Text
	Result         []byte
	RetryCount     int32
	MaxRetries     int32
	TimeoutSeconds int32
	LastFailedAt   pgtype.Timestamptz
	CreatedAt      pgtype.Timestamptz
	UpdatedAt      pgtype.Timestamptz
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type ListEligibleTasksParams

type ListEligibleTasksParams struct {
	RunAt pgtype.Timestamptz
	Limit int32
}

type PostgresTaskRepository

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

func (*PostgresTaskRepository) Create

func (r *PostgresTaskRepository) Create(ctx context.Context, task *domain.Task) error

func (*PostgresTaskRepository) Get

func (*PostgresTaskRepository) ListEligible

func (r *PostgresTaskRepository) ListEligible(ctx context.Context, now time.Time, limit int) ([]*domain.Task, error)

func (*PostgresTaskRepository) ListTasks

func (r *PostgresTaskRepository) ListTasks(ctx context.Context, filter *domain.TaskFilter) ([]*domain.Task, error)

func (*PostgresTaskRepository) ReleaseTasks

func (r *PostgresTaskRepository) ReleaseTasks(ctx context.Context, workerID string) error

func (*PostgresTaskRepository) Update

func (r *PostgresTaskRepository) Update(ctx context.Context, task *domain.Task) error

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateTask

func (q *Queries) CreateTask(ctx context.Context, arg CreateTaskParams) error

func (*Queries) GetTask

func (q *Queries) GetTask(ctx context.Context, id pgtype.UUID) (Task, error)

func (*Queries) ListEligibleTasks

func (q *Queries) ListEligibleTasks(ctx context.Context, arg ListEligibleTasksParams) ([]Task, error)

func (*Queries) ReleaseTasks

func (q *Queries) ReleaseTasks(ctx context.Context, workerID pgtype.Text) error

func (*Queries) UpdateTask

func (q *Queries) UpdateTask(ctx context.Context, arg UpdateTaskParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type Task

type Task struct {
	ID             pgtype.UUID
	ClientID       string
	TaskType       string
	Payload        []byte
	State          string
	RunAt          pgtype.Timestamptz
	WorkerID       pgtype.Text
	Result         []byte
	RetryCount     int32
	MaxRetries     int32
	TimeoutSeconds int32
	LastFailedAt   pgtype.Timestamptz
	CreatedAt      pgtype.Timestamptz
	UpdatedAt      pgtype.Timestamptz
}

type UpdateTaskParams

type UpdateTaskParams struct {
	ID           pgtype.UUID
	State        string
	WorkerID     pgtype.Text
	Result       []byte
	RetryCount   int32
	LastFailedAt pgtype.Timestamptz
	RunAt        pgtype.Timestamptz
}

Jump to

Keyboard shortcuts

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