operationpostgres

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package operationpostgres provides a supported Postgres-backed operation repository.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidTable reports that a configured table name is not a safe SQL identifier.
	ErrInvalidTable = errors.New("invalid operation table")
	// ErrOperationNotFound reports that an operation row was not found for the tenant.
	ErrOperationNotFound = errors.New("operation not found")
	// ErrStoreNotConfigured reports that the store or pool was not configured.
	ErrStoreNotConfigured = errors.New("operation postgres store not configured")
	// ErrTenantRequired reports that an operation write/read was attempted without tenant context.
	ErrTenantRequired = errors.New("operation tenant id is required")
)

Functions

func TenantIDFromContext

func TenantIDFromContext(ctx context.Context) (string, bool)

TenantIDFromContext returns the tenant ID stored by WithTenantID.

func WithTenantID

func WithTenantID(ctx context.Context, tenantID string) context.Context

WithTenantID stores a tenant ID in ctx for repository operations.

Types

type Options

type Options struct {
	Table string
	Clock func() time.Time
}

Options configures the Postgres operation store.

type Store

type Store[T any] struct {
	Pool ports.DatabasePool
	// contains filtered or unexported fields
}

Store persists pollable operation resources in Postgres.

func New

func New[T any](pool ports.DatabasePool, opts Options) *Store[T]

New creates a Postgres-backed operation repository.

func (*Store[T]) CreateOperation

func (s *Store[T]) CreateOperation(ctx context.Context, operation operations.Operation[T]) error

CreateOperation inserts an operation resource for the tenant in ctx.

func (*Store[T]) GetOperation

func (s *Store[T]) GetOperation(ctx context.Context, id string) (operations.Operation[T], bool, error)

GetOperation loads an operation resource for the tenant in ctx.

func (*Store[T]) HealthChecker

func (s *Store[T]) HealthChecker() ports.HealthChecker

HealthChecker returns a Postgres operation dependency health checker.

func (*Store[T]) UpdateOperation

func (s *Store[T]) UpdateOperation(ctx context.Context, operation operations.Operation[T]) error

UpdateOperation updates an operation resource for the tenant in ctx.

Jump to

Keyboard shortcuts

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