Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBindingMisconfigured = errors.New("approval: business binding misconfigured")
ErrBindingMisconfigured signals that a Flow with BindingMode=business is missing one of the required columns (business_table / business_pk_field / business_status_field), carries an unsafe identifier, or resolved to an empty record id. The Listener acknowledges instead of retrying: a misconfiguration does not heal by retry.
var Module = fx.Module( "vef:approval:binding", fx.Provide( NewNoopRefProvider, NewIdentityResolver, NewWriter, NewListener, ), fx.Invoke(func(l *Listener) error { return l.Start() }), )
Module provides the engine-owned write-back Writer (with its default no-op BusinessRefProvider and identity BusinessRefResolver) and starts the Listener that runs the write-back asynchronously when InstanceCompletedEvent fires. Hosts replace the provider / resolver via vef.SupplyBusinessRefProvider / vef.SupplyBusinessRefResolver; the Writer itself is not an extension point.
Reliability note: the Listener is best-effort under the default in-memory event transport — a process crash between event publication and listener execution drops the write-back. Production deployments that rely on business-table consistency MUST route approval.instance.completed through the framework's outbox transport so the listener retries until acknowledged. The Listener publishes InstanceBindingFailedEvent on persistent failure so operators / saga workers can compensate; misconfigured flows (ErrBindingMisconfigured) ack immediately to avoid an infinite retry loop.
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.
Types ¶
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener subscribes to InstanceCompletedEvent and runs the engine-owned business write-back asynchronously, decoupled from the approval transaction.
Failure semantics: if the write-back returns an error, the listener publishes InstanceBindingFailedEvent so operators (or compensating workers) can retry. The approval status itself is never rolled back — the workflow has already decided.
func NewListener ¶
NewListener constructs the listener around the engine-owned Writer.
type Writer ¶ added in v0.35.0
type Writer struct {
// contains filtered or unexported fields
}
Writer performs the engine-owned write-back of approval outcomes onto the host's business table when Flow.BindingMode == BindingBusiness. It is not an extension point: hosts influence which row it targets through approval.BusinessRefResolver and extend around it with lifecycle hooks or event subscriptions, but the write-back itself belongs to the engine.
func NewWriter ¶ added in v0.35.0
func NewWriter(resolver approval.BusinessRefResolver) *Writer
NewWriter constructs the Writer around the ref resolver.
func (*Writer) WriteBackStatus ¶ added in v0.35.0
func (w *Writer) WriteBackStatus(ctx context.Context, db orm.DB, flow *approval.Flow, instance *approval.Instance, finalStatus approval.InstanceStatus) error
WriteBackStatus writes finalStatus into the business table's status column, targeting the row whose pk column matches the resolved BusinessRef. Skipped when the flow is not business-bound or the instance carries no BusinessRef. Misconfigured flows return ErrBindingMisconfigured; resolver failures propagate as transient errors so the outbox can retry.