46 lines
1.0 KiB
Python
46 lines
1.0 KiB
Python
"""Echo executor for testing and debugging."""
|
|
|
|
from typing import Any
|
|
|
|
from app.executors.base import BaseExecutor, ExecutionResult
|
|
|
|
|
|
class EchoExecutor(BaseExecutor):
|
|
"""Simple echo executor that returns the payload as-is.
|
|
|
|
Used for testing connectivity and task flow.
|
|
|
|
Payload:
|
|
{
|
|
"message": "string to echo back"
|
|
}
|
|
|
|
Result:
|
|
{
|
|
"echoed": "string that was sent"
|
|
}
|
|
"""
|
|
|
|
@property
|
|
def task_type(self) -> str:
|
|
return "ECHO"
|
|
|
|
async def execute(self, payload: dict[str, Any]) -> ExecutionResult:
|
|
"""Echo back the payload message.
|
|
|
|
Args:
|
|
payload: Must contain "message" field
|
|
|
|
Returns:
|
|
ExecutionResult with the echoed message
|
|
"""
|
|
self.validate_payload(payload, ["message"])
|
|
|
|
message = payload["message"]
|
|
self.logger.info("echo_executing", message=message)
|
|
|
|
return ExecutionResult(
|
|
success=True,
|
|
data={"echoed": message},
|
|
)
|