feat(fase4): add NodeExecutor architecture with basic nodes
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
34
services/flow-engine/app/nodes/base.py
Normal file
34
services/flow-engine/app/nodes/base.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Optional, Any
|
||||
from app.context import FlowContext
|
||||
|
||||
|
||||
class NodeExecutor(ABC):
|
||||
"""Base class for all node executors"""
|
||||
|
||||
@abstractmethod
|
||||
async def execute(
|
||||
self,
|
||||
config: dict,
|
||||
context: FlowContext,
|
||||
session: Any
|
||||
) -> Optional[str]:
|
||||
"""
|
||||
Execute the node logic.
|
||||
Returns: branch name for routing (e.g., "default", "true", "false")
|
||||
or "wait" to pause execution
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class NodeRegistry:
|
||||
"""Registry of all available node executors"""
|
||||
_executors: dict = {}
|
||||
|
||||
@classmethod
|
||||
def register(cls, node_type: str, executor: NodeExecutor):
|
||||
cls._executors[node_type] = executor
|
||||
|
||||
@classmethod
|
||||
def get(cls, node_type: str) -> Optional[NodeExecutor]:
|
||||
return cls._executors.get(node_type)
|
||||
Reference in New Issue
Block a user