Documentation
¶
Index ¶
- Variables
- func NewIdentityResolver() approval.BusinessRefResolver
- func NewNoopRefProvider() approval.BusinessRefProvider
- func NormalizeConfig(mode approval.BindingMode, config *approval.BusinessBindingConfig) (*approval.BusinessBindingConfig, error)
- type ConfigValidator
- type Projector
- type Worker
- type Writer
Constants ¶
This section is empty.
Variables ¶
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.
var Module = fx.Module( "vef:approval:binding", fx.Provide( NewNoopRefProvider, NewIdentityResolver, NewConfigValidator, NewWriter, fx.Annotate( NewProjector, fx.As(fx.Self()), fx.As(new(engine.InstanceProjector)), ), NewWorker, ), fx.Invoke(registerProjectionJob), )
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
func NormalizeConfig(mode approval.BindingMode, config *approval.BusinessBindingConfig) (*approval.BusinessBindingConfig, error)
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.
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 (*Worker) ProcessPending ¶ added in v0.38.0
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.
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.