Documentation
¶
Overview ¶
Package uow owns one invocation-scoped mutation unit of work.
Index ¶
- Variables
- func BindingOrder(ctx context.Context) string
- func Enter(ctx context.Context, name string) (context.Context, *Scope, *Frame, bool, error)
- func FromContext(ctx context.Context) (*Scope, *Frame, bool)
- func NewRoot(ctx context.Context, name string) (context.Context, *Scope, *Frame)
- func PrepareChild(ctx context.Context, relation Relation, order string) context.Context
- func Propagate(source, destination context.Context) context.Context
- func ReserveBindingOrder(ctx context.Context) (string, error)
- func WithBindingOrder(ctx context.Context, order string) context.Context
- func WithBindingOrderIndex(ctx context.Context, index int) context.Context
- type Buffer
- func (b *Buffer) Append(value any) error
- func (b *Buffer) Flush(ctx context.Context, table string) error
- func (b *Buffer) Reconcile(values []any) error
- func (b *Buffer) SetBatchExecutor(execute func(context.Context, *sql.Tx, []any) error)
- func (b *Buffer) Transaction(ctx context.Context) (*sql.Tx, error)
- func (b *Buffer) UseTransaction(ctx context.Context, fn func(*sql.Tx) error) error
- type Frame
- type Operation
- type Relation
- type Scope
Constants ¶
This section is empty.
Variables ¶
var ( ErrCompleted = errors.New("mutation unit of work is completed") ErrFailed = errors.New("mutation unit of work has failed") ErrFrameSealed = errors.New("component mutation frame is sealed") ErrBindingFlush = errors.New("cannot flush a binding child while its ancestor is open") ErrTransactionConflict = errors.New("conflicting transaction for database") ErrTransactionAccess = errors.New("direct transaction access is unavailable in invocation mode") )
Functions ¶
func BindingOrder ¶
BindingOrder returns a previously reserved binding declaration order.
func Enter ¶
Enter creates a child frame when ctx was prepared for dispatch. Otherwise it returns the current root frame, or creates a root for an external entry.
func FromContext ¶
FromContext returns the active scope and frame.
func PrepareChild ¶
PrepareChild marks the next component dispatch as a child of the active frame.
func Propagate ¶
Propagate copies only Datly's private invocation carrier from source to destination. Dispatcher closures use it so caller cancellation is retained while a nested session cannot accidentally lose the active unit of work.
func ReserveBindingOrder ¶
ReserveBindingOrder allocates a stable frame-wide declaration slot before a binding resolver goroutine is started.
func WithBindingOrder ¶
WithBindingOrder records the declaration order reserved by the parameter resolver before concurrently evaluating component-valued bindings.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer associates statements with one component frame and database source.
func (*Buffer) Append ¶
Append adds one operation at the exact current position in the frame timeline.
func (*Buffer) Flush ¶
Flush executes the causal prefix ending at the requested table for b's database.
func (*Buffer) Reconcile ¶
Reconcile replaces this buffer's observed entries with the exact execution sequence produced by template materialization while retaining child markers.
func (*Buffer) SetBatchExecutor ¶
SetBatchExecutor enables batching for contiguous operations that expose the same non-empty BatchKey. Ordering barriers are never crossed.
func (*Buffer) Transaction ¶
Transaction returns the database transaction owned by the invocation scope. The caller may issue work through it, but must not commit or roll it back; completion remains the responsibility of the root scope.
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
Frame owns the mutation timeline of one component invocation.
func (*Frame) DebugLabel ¶
DebugLabel identifies a frame in diagnostics without exposing its mutable timeline or ownership internals.
type Operation ¶
type Operation struct {
// contains filtered or unexported fields
}
Operation is one ordered buffered mutation.
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope coordinates component frames and database transactions for one root operation.
func (*Scope) AdoptTransaction ¶
AdoptTransaction registers a caller-owned transaction for db before child binding evaluation can lazily create a local transaction for that database.
func (*Scope) IsCompleted ¶
IsCompleted reports whether root completion has run.