Documentation
¶
Overview ¶
flow/executor.go
Index ¶
- func GetCompensation(effect effectus.Effect) string
- func Run(program *Program, executor effectus.Executor) (interface{}, error)
- func RunContext(ctx context.Context, program *Program, executor effectus.Executor) (interface{}, error)
- type CompiledFlow
- type Compiler
- func (c *Compiler) CompileFile(path string, schema effectus.SchemaInfo) (effectus.Spec, error)
- func (c *Compiler) CompileFiles(paths []string, schema effectus.SchemaInfo) (effectus.Spec, error)
- func (c *Compiler) CompileParsedFile(file *ast.File, path string, schema effectus.SchemaInfo) (effectus.Spec, error)
- type Executor
- type ExecutorOption
- type Program
- func Atomic(name string, program *Program) *Program
- func Do(effect effectus.Effect, cont func(interface{}) *Program) *Program
- func DoWithCompensation(effect effectus.Effect, compensation string, cont func(interface{}) *Program) *Program
- func Error(err error) *Program
- func FromList(effects []effectus.Effect) *Program
- func FromListWithCompensation(effects []effectus.Effect, compensations map[string]string) *Program
- func Pure(value interface{}) *Program
- func Transaction(sagaID, name string, program *Program) *Program
- func (p *Program) Bind(f func(interface{}) *Program) *Program
- func (p *Program) FlatMap(f func(interface{}) *Program) *Program
- func (p *Program) IsTransactional() bool
- func (p *Program) Map(f func(interface{}) interface{}) *Program
- func (p *Program) Then(next *Program) *Program
- func (p *Program) ToAtomic(name string) *Program
- func (p *Program) ToTransaction(sagaID, name string) *Program
- func (p *Program) WithCompensation(getCompensation func(verb string) string) *Program
- type ProgramTag
- type Spec
- type TransactionInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCompensation ¶
GetCompensation extracts compensation information from an effect
Types ¶
type CompiledFlow ¶
type CompiledFlow struct {
Name string
Priority int
Predicates []*schema.Predicate
Program *Program
FactPaths []string
SourceFile string
}
CompiledFlow represents a flow after compilation
func (*CompiledFlow) GetPriority ¶
func (cf *CompiledFlow) GetPriority() int
GetPriority implements the common.Prioritized interface
type Compiler ¶
type Compiler struct{}
Compiler implements the Compiler interface for flow-style rules
func (*Compiler) CompileFile ¶
CompileFile compiles a rule file into a flow-style spec
func (*Compiler) CompileFiles ¶
CompileFiles compiles multiple rule files into a single flow-style spec
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor is the main executor for flow programs with saga and capability support
func NewExecutor ¶
func NewExecutor(verbRegistry common.VerbRegistry, options ...ExecutorOption) *Executor
NewExecutor creates a new executor for flow programs
type ExecutorOption ¶
type ExecutorOption func(*Executor)
ExecutorOption defines an option for configuring the flow executor
func WithCapabilitySystem ¶
func WithCapabilitySystem(capSystem *capability.CapabilitySystem) ExecutorOption
WithCapabilitySystem enables capability-based locking
func WithSaga ¶
func WithSaga(store schema.SagaStore) ExecutorOption
WithSaga enables saga-style compensation for failed executions
type Program ¶
type Program struct {
Tag ProgramTag
Pure interface{}
Effect effectus.Effect
Transaction *TransactionInfo
Continue func(interface{}) *Program
}
Program represents a free monad over Effect with saga transaction support
func DoWithCompensation ¶
func DoWithCompensation(effect effectus.Effect, compensation string, cont func(interface{}) *Program) *Program
DoWithCompensation creates a program that performs an effect with compensation info
func FromList ¶
FromList converts a list of Effects to a Program This is the "canonical embedding" α from the theoretical foundation
func FromListWithCompensation ¶
FromListWithCompensation converts effects to a program with compensation
func Transaction ¶
Transaction creates a saga transaction boundary around a program
func (*Program) IsTransactional ¶
IsTransactional returns true if the program contains any transaction boundaries
func (*Program) ToTransaction ¶
ToTransaction wraps a program in a saga transaction
type ProgramTag ¶
type ProgramTag int
ProgramTag identifies the type of program node
const ( // PureProgramTag is a pure value PureProgramTag ProgramTag = iota // EffectProgramTag is an effect with a continuation EffectProgramTag // TransactionProgramTag marks a saga transaction boundary TransactionProgramTag )
type Spec ¶
type Spec struct {
Name string
Flows []*CompiledFlow
FactPaths []string
SagaEnabled bool // Whether to use saga execution
SagaStore schema.SagaStore // Saga store for transaction management
CapSystem *capability.CapabilitySystem // Capability system for locking
VerbRegistry common.VerbRegistry // Verb registry for execution
}
Spec implements the effectus.Spec interface for flow rules
func (*Spec) RequiredFacts ¶
RequiredFacts returns the list of fact paths required by this spec
type TransactionInfo ¶
type TransactionInfo struct {
SagaID string // Unique saga identifier
Name string // Human-readable transaction name
Compensation string // Inverse verb for compensation
Program *Program // The program to execute within the transaction
IsAtomic bool // Whether this transaction should be atomic
}
TransactionInfo holds metadata for saga transaction boundaries
func ExtractTransactions ¶
func ExtractTransactions(program *Program) []*TransactionInfo
ExtractTransactions extracts all transaction boundaries from a program This is useful for saga executors to understand the transaction structure