| 
				
					
						 | 
			2 个月前 | |
|---|---|---|
| .. | ||
| command_channels | 2 个月前 | |
| command_processing | 2 个月前 | |
| domain | 2 个月前 | |
| entities | 2 个月前 | |
| error_handling | 2 个月前 | |
| event_management | 2 个月前 | |
| graph_traversal | 2 个月前 | |
| layers | 2 个月前 | |
| orchestration | 2 个月前 | |
| output_registry | 2 个月前 | |
| protocols | 2 个月前 | |
| response_coordinator | 2 个月前 | |
| state_management | 2 个月前 | |
| worker_management | 2 个月前 | |
| README.md | 2 个月前 | |
| __init__.py | 2 个月前 | |
| graph_engine.py | 2 个月前 | |
| manager.py | 2 个月前 | |
| worker.py | 2 个月前 | |
Queue-based workflow execution engine for parallel graph processing.
The engine uses a modular architecture with specialized packages:
domain/) - Core models: ExecutionContext, GraphExecution, NodeExecutionevent_management/) - Event handling, collection, and emissionstate_management/) - Thread-safe state tracking for nodes and edgeserror_handling/) - Strategy-based error recovery (retry, abort, fail-branch, default-value)graph_traversal/) - Node readiness, edge processing, branch handlingcommand_processing/) - External command handling (abort, pause, resume)worker_management/) - Dynamic worker pool with auto-scalingorchestration/) - Main event loop and execution coordinationoutput_registry/) - Thread-safe storage for node outputsresponse_coordinator/) - Ordered streaming of response nodescommand_channels/) - Command transport (InMemory/Redis)layers/) - Pluggable middleware for extensionsclassDiagram
    class GraphEngine {
        +run()
        +add_layer()
    }
    
    class Domain {
        ExecutionContext
        GraphExecution
        NodeExecution
    }
    
    class EventManagement {
        EventHandlerRegistry
        EventCollector
        EventEmitter
    }
    
    class StateManagement {
        NodeStateManager
        EdgeStateManager
        ExecutionTracker
    }
    
    class WorkerManagement {
        WorkerPool
        WorkerFactory
        DynamicScaler
        ActivityTracker
    }
    
    class GraphTraversal {
        NodeReadinessChecker
        EdgeProcessor
        BranchHandler
        SkipPropagator
    }
    
    class Orchestration {
        Dispatcher
        ExecutionCoordinator
    }
    
    class ErrorHandling {
        ErrorHandler
        RetryStrategy
        AbortStrategy
        FailBranchStrategy
    }
    
    class CommandProcessing {
        CommandProcessor
        AbortCommandHandler
    }
    
    class CommandChannels {
        InMemoryChannel
        RedisChannel
    }
    
    class OutputRegistry {
        <<Storage>>
        Scalar Values
        Streaming Data
    }
    
    class ResponseCoordinator {
        Session Management
        Path Analysis
    }
    
    class Layers {
        <<Plugin>>
        DebugLoggingLayer
    }
    
    GraphEngine --> Orchestration : coordinates
    GraphEngine --> Layers : extends
    
    Orchestration --> EventManagement : processes events
    Orchestration --> WorkerManagement : manages scaling
    Orchestration --> CommandProcessing : checks commands
    Orchestration --> StateManagement : monitors state
    
    WorkerManagement --> StateManagement : consumes ready queue
    WorkerManagement --> EventManagement : produces events
    WorkerManagement --> Domain : executes nodes
    
    EventManagement --> ErrorHandling : failed events
    EventManagement --> GraphTraversal : success events
    EventManagement --> ResponseCoordinator : stream events
    EventManagement --> Layers : notifies
    
    GraphTraversal --> StateManagement : updates states
    GraphTraversal --> Domain : checks graph
    
    CommandProcessing --> CommandChannels : fetches commands
    CommandProcessing --> Domain : modifies execution
    
    ErrorHandling --> Domain : handles failures
    
    StateManagement --> Domain : tracks entities
    
    ResponseCoordinator --> OutputRegistry : reads outputs
    
    Domain --> OutputRegistry : writes outputs
from core.workflow.graph_engine import GraphEngine
from core.workflow.graph_engine.command_channels import InMemoryChannel
# Create and run engine
engine = GraphEngine(
    tenant_id="tenant_1",
    app_id="app_1",
    workflow_id="workflow_1",
    graph=graph,
    command_channel=InMemoryChannel(),
)
# Stream execution events
for event in engine.run():
    handle_event(event)