Documentation
¶
Overview ¶
Package postgres provides the PostgreSQL-backed implementation of the workflow.Repository port, built on native pgx.
Index ¶
- type Repository
- func (r *Repository) AppendEvent(ctx context.Context, db pgxtx.DBTX, e *workflow.Event) error
- func (r *Repository) Create(ctx context.Context, db pgxtx.DBTX, c *workflow.Case) error
- func (r *Repository) GetByExternalID(ctx context.Context, db pgxtx.DBTX, domain, externalID string) (*workflow.Case, error)
- func (r *Repository) GetByID(ctx context.Context, db pgxtx.DBTX, id uuid.UUID) (*workflow.Case, error)
- func (r *Repository) ListByEligibility(ctx context.Context, db pgxtx.DBTX, f workflow.InboxFilter) ([]workflow.Case, error)
- func (r *Repository) ListEvents(ctx context.Context, db pgxtx.DBTX, caseID uuid.UUID) ([]workflow.Event, error)
- func (r *Repository) Update(ctx context.Context, db pgxtx.DBTX, c *workflow.Case) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository struct{}
Repository implements workflow.Repository using pgx. It is stateless: every method receives the pgxtx.DBTX to run against, so the caller decides whether to use a plain pool connection or an existing transaction.
func NewRepository ¶
func NewRepository() *Repository
NewRepository creates a stateless PostgreSQL-backed workflow repository.
func (*Repository) AppendEvent ¶
AppendEvent inserts e, computing its Seq in SQL as COALESCE(MAX(seq), 0) + 1 for the case so concurrent appends cannot silently collide — the UNIQUE(case_id, seq) constraint is the backstop. e.Seq is overwritten with the value actually persisted.
func (*Repository) Create ¶
Create inserts a new case. A unique-violation on (domain, external_id) is mapped to workflow.ErrCaseExists.
func (*Repository) GetByExternalID ¶
func (r *Repository) GetByExternalID(ctx context.Context, db pgxtx.DBTX, domain, externalID string) (*workflow.Case, error)
GetByExternalID retrieves a single case by its (domain, external_id) pair.
func (*Repository) GetByID ¶
func (r *Repository) GetByID(ctx context.Context, db pgxtx.DBTX, id uuid.UUID) (*workflow.Case, error)
GetByID retrieves a single case by its primary key.
func (*Repository) ListByEligibility ¶
func (r *Repository) ListByEligibility(ctx context.Context, db pgxtx.DBTX, f workflow.InboxFilter) ([]workflow.Case, error)
ListByEligibility returns open cases matching f. States, when non-empty, restricts results to cases whose current node is one of those IDs — the mapping from Position/Unit to that set of node IDs is resolved by the caller (see workflow.Engine.EligibilityFor), not by this query.