Documentation
¶
Overview ¶
Package executor implements the imperative shell for executing plans. It provides transaction safety with two-phase commit and rollback capabilities.
Index ¶
- type Checkpoint
- func (c *Checkpoint) GetOperation(id domain.OperationID) (domain.Operation, bool)
- func (c *Checkpoint) Len() int
- func (c *Checkpoint) ListOperations() []domain.Operation
- func (c *Checkpoint) Lookup(id domain.OperationID) domain.Operation
- func (c *Checkpoint) Record(id domain.OperationID, op domain.Operation)
- type CheckpointID
- type CheckpointStore
- type ExecutionResult
- type Executor
- type InstrumentedExecutor
- type MemoryCheckpointStore
- type Opts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checkpoint ¶
type Checkpoint struct {
ID CheckpointID
CreatedAt time.Time
// contains filtered or unexported fields
}
Checkpoint records executed operations for rollback.
func (*Checkpoint) GetOperation ¶
func (c *Checkpoint) GetOperation(id domain.OperationID) (domain.Operation, bool)
GetOperation retrieves an operation by ID with thread safety. Returns the operation and true if found, or nil and false if not found.
func (*Checkpoint) Len ¶
func (c *Checkpoint) Len() int
Len returns the number of operations in the checkpoint.
func (*Checkpoint) ListOperations ¶
func (c *Checkpoint) ListOperations() []domain.Operation
ListOperations returns a snapshot of all operations in the checkpoint. The returned slice is a copy and safe to use concurrently.
func (*Checkpoint) Lookup ¶
func (c *Checkpoint) Lookup(id domain.OperationID) domain.Operation
Lookup retrieves an operation from the checkpoint. Returns nil if the operation is not found.
func (*Checkpoint) Record ¶
func (c *Checkpoint) Record(id domain.OperationID, op domain.Operation)
Record stores an executed operation in the checkpoint.
type CheckpointStore ¶
type CheckpointStore interface {
Create(ctx context.Context) *Checkpoint
Delete(ctx context.Context, id CheckpointID) error
Restore(ctx context.Context, id CheckpointID) (*Checkpoint, error)
}
CheckpointStore manages checkpoint persistence.
type ExecutionResult ¶
type ExecutionResult struct {
Executed []domain.OperationID
Failed []domain.OperationID
RolledBack []domain.OperationID
Errors []error
}
ExecutionResult contains the outcome of plan execution.
func (ExecutionResult) PartialFailure ¶
func (r ExecutionResult) PartialFailure() bool
PartialFailure returns true if some but not all operations succeeded.
func (ExecutionResult) Success ¶
func (r ExecutionResult) Success() bool
Success returns true if all operations executed successfully.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor executes validated plans with transaction safety.
type InstrumentedExecutor ¶
type InstrumentedExecutor struct {
// contains filtered or unexported fields
}
InstrumentedExecutor wraps Executor with metrics collection.
func NewInstrumented ¶
func NewInstrumented(inner *Executor, metrics domain.Metrics) *InstrumentedExecutor
NewInstrumented creates an executor with metrics instrumentation.
func (*InstrumentedExecutor) Execute ¶
func (e *InstrumentedExecutor) Execute(ctx context.Context, plan domain.Plan) domain.Result[ExecutionResult]
Execute executes a plan with metrics collection.
type MemoryCheckpointStore ¶
type MemoryCheckpointStore struct {
// contains filtered or unexported fields
}
MemoryCheckpointStore keeps checkpoints in memory. Suitable for testing and simple cases where persistence is not required.
func NewMemoryCheckpointStore ¶
func NewMemoryCheckpointStore() *MemoryCheckpointStore
NewMemoryCheckpointStore creates a new in-memory checkpoint store.
func (*MemoryCheckpointStore) Create ¶
func (s *MemoryCheckpointStore) Create(ctx context.Context) *Checkpoint
func (*MemoryCheckpointStore) Delete ¶
func (s *MemoryCheckpointStore) Delete(ctx context.Context, id CheckpointID) error
func (*MemoryCheckpointStore) Restore ¶
func (s *MemoryCheckpointStore) Restore(ctx context.Context, id CheckpointID) (*Checkpoint, error)