postgres

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStores

func NewStores(ctx context.Context, dsn string, maxOpen, maxIdle int) (*store.Stores, error)

func NewStoresFromDB

func NewStoresFromDB(db *DB) (*store.Stores, error)

NewStoresFromDB builds a Stores bundle from an existing DB connection. Used by integration tests that manage their own database lifecycle.

Types

type ApprovalStore

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

func NewApprovalStore

func NewApprovalStore(db *DB) *ApprovalStore

func (*ApprovalStore) CountByDecisionAndStage

func (s *ApprovalStore) CountByDecisionAndStage(ctx context.Context, requestID uuid.UUID, decision model.Decision, stageIndex int) (int, error)

func (*ApprovalStore) Create

func (s *ApprovalStore) Create(ctx context.Context, approval *model.Approval) error

func (*ApprovalStore) ExistsByCheckerAndStage

func (s *ApprovalStore) ExistsByCheckerAndStage(ctx context.Context, requestID uuid.UUID, checkerID string, stageIndex int) (bool, error)

func (*ApprovalStore) ListByRequestID

func (s *ApprovalStore) ListByRequestID(ctx context.Context, requestID uuid.UUID) ([]model.Approval, error)

type AuditStore

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

func NewAuditStore

func NewAuditStore(db *DB) *AuditStore

func (*AuditStore) Create

func (s *AuditStore) Create(ctx context.Context, log *model.AuditLog) error

func (*AuditStore) ListByRequestID

func (s *AuditStore) ListByRequestID(ctx context.Context, requestID uuid.UUID) ([]model.AuditLog, error)

type DB

type DB struct {
	Pool DBTX // public: used by stores — can be pool or tx
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, dsn string, maxOpen, maxIdle int) (*DB, error)

func (*DB) Close

func (db *DB) Close()

func (*DB) Health

func (db *DB) Health(ctx context.Context) error

func (*DB) Name

func (db *DB) Name() string

type DBTX

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

DBTX is the common query interface shared by *pgxpool.Pool and pgx.Tx. All postgres stores use this interface for their queries, allowing them to operate on either a connection pool or a transaction.

type OperatorStore

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

func NewOperatorStore

func NewOperatorStore(db *DB) *OperatorStore

func (*OperatorStore) Count

func (s *OperatorStore) Count(ctx context.Context) (int, error)

func (*OperatorStore) Create

func (s *OperatorStore) Create(ctx context.Context, operator *model.Operator) error

func (*OperatorStore) Delete

func (s *OperatorStore) Delete(ctx context.Context, id uuid.UUID) error

func (*OperatorStore) GetByID

func (s *OperatorStore) GetByID(ctx context.Context, id uuid.UUID) (*model.Operator, error)

func (*OperatorStore) GetByUsername

func (s *OperatorStore) GetByUsername(ctx context.Context, username string) (*model.Operator, error)

func (*OperatorStore) List

func (*OperatorStore) Update

func (s *OperatorStore) Update(ctx context.Context, operator *model.Operator) error

type OutboxStore

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

func NewOutboxStore

func NewOutboxStore(db *DB) *OutboxStore

func (*OutboxStore) ClaimBatch

func (s *OutboxStore) ClaimBatch(ctx context.Context, limit int) ([]model.OutboxEntry, error)

func (*OutboxStore) CountByStatus

func (s *OutboxStore) CountByStatus(ctx context.Context, tenantID *string, since *time.Time) (map[string]int, error)

func (*OutboxStore) CreateBatch

func (s *OutboxStore) CreateBatch(ctx context.Context, entries []model.OutboxEntry) error

func (*OutboxStore) DeleteDelivered

func (s *OutboxStore) DeleteDelivered(ctx context.Context, olderThan time.Time) (int64, error)

func (*OutboxStore) GetByID

func (s *OutboxStore) GetByID(ctx context.Context, id uuid.UUID) (*model.OutboxEntry, error)

func (*OutboxStore) List

func (s *OutboxStore) List(ctx context.Context, filter store.OutboxFilter) ([]model.OutboxEntry, int, error)

func (*OutboxStore) MarkDelivered

func (s *OutboxStore) MarkDelivered(ctx context.Context, id uuid.UUID) error

func (*OutboxStore) MarkFailed

func (s *OutboxStore) MarkFailed(ctx context.Context, id uuid.UUID, attempts int, lastError string) error

func (*OutboxStore) MarkRetry

func (s *OutboxStore) MarkRetry(ctx context.Context, id uuid.UUID, attempts int, lastError string, nextRetryAt time.Time) error

func (*OutboxStore) ResetAllFailed added in v0.1.2

func (s *OutboxStore) ResetAllFailed(ctx context.Context, tenantID *string) (int64, error)

func (*OutboxStore) ResetAllFailedForRequest

func (s *OutboxStore) ResetAllFailedForRequest(ctx context.Context, requestID uuid.UUID) (int64, error)

func (*OutboxStore) ResetForRetry

func (s *OutboxStore) ResetForRetry(ctx context.Context, id uuid.UUID) error

type PolicyStore

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

func NewPolicyStore

func NewPolicyStore(db *DB) *PolicyStore

func (*PolicyStore) Create

func (s *PolicyStore) Create(ctx context.Context, policy *model.Policy) error

func (*PolicyStore) Delete

func (s *PolicyStore) Delete(ctx context.Context, id uuid.UUID) error

func (*PolicyStore) DistinctRequestTypes added in v0.1.2

func (s *PolicyStore) DistinctRequestTypes(ctx context.Context) ([]string, error)

func (*PolicyStore) GetByID

func (s *PolicyStore) GetByID(ctx context.Context, id uuid.UUID) (*model.Policy, error)

func (*PolicyStore) GetByRequestType

func (s *PolicyStore) GetByRequestType(ctx context.Context, requestType string) (*model.Policy, error)

func (*PolicyStore) List

func (s *PolicyStore) List(ctx context.Context, filter store.PolicyFilter) ([]model.Policy, int, error)

func (*PolicyStore) Update

func (s *PolicyStore) Update(ctx context.Context, policy *model.Policy) error

type RequestStore

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

func NewRequestStore

func NewRequestStore(db *DB) *RequestStore

func (*RequestStore) Create

func (s *RequestStore) Create(ctx context.Context, req *model.Request) error

func (*RequestStore) FindPendingByFingerprint

func (s *RequestStore) FindPendingByFingerprint(ctx context.Context, reqType string, fingerprint string) (*model.Request, error)

func (*RequestStore) GetByID

func (s *RequestStore) GetByID(ctx context.Context, id uuid.UUID) (*model.Request, error)

func (*RequestStore) GetByIDForUpdate

func (s *RequestStore) GetByIDForUpdate(ctx context.Context, id uuid.UUID) (*model.Request, error)

func (*RequestStore) GetByIdempotencyKey

func (s *RequestStore) GetByIdempotencyKey(ctx context.Context, key string) (*model.Request, error)

func (*RequestStore) List

func (s *RequestStore) List(ctx context.Context, filter store.RequestFilter) ([]model.Request, int, error)

func (*RequestStore) ListExpired

func (s *RequestStore) ListExpired(ctx context.Context) ([]model.Request, error)

func (*RequestStore) UpdateStageAndStatus

func (s *RequestStore) UpdateStageAndStatus(ctx context.Context, id uuid.UUID, stage int, status model.RequestStatus) error

func (*RequestStore) UpdateStatus

func (s *RequestStore) UpdateStatus(ctx context.Context, id uuid.UUID, status model.RequestStatus) error

type TenantStore

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

func NewTenantStore

func NewTenantStore(db *DB) *TenantStore

func (*TenantStore) Create

func (s *TenantStore) Create(ctx context.Context, tenant *model.Tenant) error

func (*TenantStore) Delete

func (s *TenantStore) Delete(ctx context.Context, id uuid.UUID) error

func (*TenantStore) GetByID

func (s *TenantStore) GetByID(ctx context.Context, id uuid.UUID) (*model.Tenant, error)

func (*TenantStore) GetBySlug

func (s *TenantStore) GetBySlug(ctx context.Context, slug string) (*model.Tenant, error)

func (*TenantStore) List

func (s *TenantStore) List(ctx context.Context, filter store.TenantFilter) ([]model.Tenant, int, error)

type WebhookStore

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

func NewWebhookStore

func NewWebhookStore(db *DB) *WebhookStore

func (*WebhookStore) Create

func (s *WebhookStore) Create(ctx context.Context, webhook *model.Webhook) error

func (*WebhookStore) Delete

func (s *WebhookStore) Delete(ctx context.Context, id uuid.UUID) error

func (*WebhookStore) GetByID

func (s *WebhookStore) GetByID(ctx context.Context, id uuid.UUID) (*model.Webhook, error)

func (*WebhookStore) List

func (s *WebhookStore) List(ctx context.Context, filter store.WebhookFilter) ([]model.Webhook, int, error)

func (*WebhookStore) ListByEventAndType

func (s *WebhookStore) ListByEventAndType(ctx context.Context, event string, requestType string) ([]model.Webhook, error)

Jump to

Keyboard shortcuts

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