binding

package
v0.38.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBindingMisconfigured     = errors.New("approval: business binding misconfigured")
	ErrInvalidBusinessRef       = errors.New("approval: invalid business reference")
	ErrBindingTargetMissing     = errors.New("approval: business binding target not found")
	ErrBindingTargetNotUnique   = errors.New("approval: business binding target is not unique")
	ErrBindingOwnershipConflict = errors.New("approval: business binding owner changed")
	ErrProjectionStateInvalid   = errors.New("approval: business projection state is invalid")
)

ErrBindingMisconfigured signals that a business-bound Flow carries an incomplete or unsafe BusinessBindingConfig.

Module provides version-pinned business projection, its default reference provider/resolver, and the durable eventual-consistency worker. Hosts can replace the provider or resolver; projection ownership and write-back remain engine-owned.

Functions

func NewIdentityResolver added in v0.35.0

func NewIdentityResolver() approval.BusinessRefResolver

NewIdentityResolver constructs the default identity resolver.

func NewNoopRefProvider added in v0.35.0

func NewNoopRefProvider() approval.BusinessRefProvider

NewNoopRefProvider constructs the default no-op provider.

func NormalizeConfig added in v0.38.0

NormalizeConfig validates the mode-dependent shape and SQL identifiers and returns a detached, canonical configuration. Key column order is normalized because equality predicates are order-independent.

Types

type ConfigValidator added in v0.38.0

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

ConfigValidator validates business binding columns against the primary database schema.

func NewConfigValidator added in v0.38.0

func NewConfigValidator(schemas schema.Service) *ConfigValidator

NewConfigValidator creates a ConfigValidator.

func (*ConfigValidator) ValidateSchema added in v0.38.0

func (v *ConfigValidator) ValidateSchema(ctx context.Context, config *approval.BusinessBindingConfig) error

ValidateSchema verifies that every configured column exists and that the key columns exactly match a complete, non-null primary or unique key.

type Projector added in v0.38.0

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

Projector owns business-target claims and advances their durable desired state. Synchronous projections are applied before the caller's transaction can commit; eventual projections are left pending for Worker.

func NewProjector added in v0.38.0

func NewProjector(
	resolver approval.BusinessRefResolver,
	writer *Writer,
	cfg *config.ApprovalConfig,
) *Projector

NewProjector constructs the business-state projector.

func (*Projector) Bind added in v0.38.0

func (p *Projector) Bind(
	ctx context.Context,
	db orm.DB,
	flow *approval.Flow,
	version *approval.FlowVersion,
	instance *approval.Instance,
) error

Bind resolves and claims a version-pinned business target for a newly inserted instance. A non-final existing owner blocks the claim; a final owner can be superseded, with the applied owner retained as the business-table CAS fence until the new desired state is written.

func (*Projector) Project added in v0.38.0

func (p *Projector) Project(ctx context.Context, db orm.DB, instance *approval.Instance) error

Project advances the desired state for an already-bound instance. It is the engine transition hook used for running, paused, and final statuses alike.

type Worker added in v0.38.0

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

Worker leases eventual projections from durable state and applies their latest desired revision. Lifecycle events are notifications only; worker correctness depends solely on the projection table.

func NewWorker added in v0.38.0

func NewWorker(db orm.DB, bus event.Bus, writer *Writer, cfg *config.ApprovalConfig) *Worker

NewWorker constructs the eventual projection worker.

func (*Worker) ProcessPending added in v0.38.0

func (w *Worker) ProcessPending(ctx context.Context) (int, error)

ProcessPending claims and processes at most the configured batch size.

func (*Worker) Retry added in v0.38.0

func (w *Worker) Retry(ctx context.Context, db orm.DB, projection *approval.BusinessProjection) error

Retry applies one locked eventual projection immediately. A business write failure is recorded on the projection and is not returned as an infrastructure error; the caller can inspect Status and LastError.

func (*Worker) Run added in v0.38.0

func (w *Worker) Run(ctx context.Context)

Run processes one configured batch. Failures are persisted and scheduled for retry; they never escape into an approval transaction.

type Writer added in v0.35.0

type Writer struct{}

Writer applies one durable projection snapshot to its host business row. It always writes the complete configured state, so retries and out-of-order lifecycle notifications cannot combine columns from different revisions.

func NewWriter added in v0.35.0

func NewWriter() *Writer

NewWriter constructs the engine-owned Writer.

func (*Writer) Write added in v0.38.0

func (*Writer) Write(ctx context.Context, db orm.DB, projection *approval.BusinessProjection) error

Write applies projection.DesiredRevision to the bound business row. When a previous owner has already been applied, the instance-ID column is checked and included in the UPDATE predicate as a compare-and-set fence.

Jump to

Keyboard shortcuts

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