prefactor_core.operations module
prefactor_core.operations module
Section titled “prefactor_core.operations module”Operation types for prefactor-core.
Operations represent discrete units of work that can be queued and processed asynchronously. Each operation type maps to a specific API action.
class prefactor_core.operations.Operation(type: ~prefactor_core.operations.OperationType, payload: dict[str, ~typing.Any], timestamp: ~datetime.datetime, idempotency_key: str | None = None, metadata: dict[str, ~typing.Any] = )
Section titled “class prefactor_core.operations.Operation(type: ~prefactor_core.operations.OperationType, payload: dict[str, ~typing.Any], timestamp: ~datetime.datetime, idempotency_key: str | None = None, metadata: dict[str, ~typing.Any] = )”Bases: object
A single operation to be queued and processed.
Operations are immutable and contain all data needed for execution. They are created synchronously and processed asynchronously by workers.
The type of operation to perform.
payload
Section titled “payload”Dictionary containing operation-specific data.
- Type: dict[str, Any]
timestamp
Section titled “timestamp”When the operation was created.
- Type: datetime.datetime
idempotency_key
Section titled “idempotency_key”Optional key for idempotent operations.
- Type: str | None
metadata
Section titled “metadata”Optional additional metadata.
- Type: dict[str, Any]
Example
Section titled “Example”from datetime import datetime, timezone
operation = Operation(
: type=OperationType.CREATE_SPAN,
payload={
“instance_id”: “inst-123”, “schema_name”: “agent:llm”, “span_id”: “span-456”
}, timestamp=datetime.now(timezone.utc), idempotency_key=”span-456”
)
idempotency_key : str | None = None
Section titled “idempotency_key : str | None = None”metadata : dict[str, Any]
Section titled “metadata : dict[str, Any]”payload : dict[str, Any]
Section titled “payload : dict[str, Any]”timestamp : datetime
Section titled “timestamp : datetime”class prefactor_core.operations.OperationType(*values)
Section titled “class prefactor_core.operations.OperationType(*values)”Bases: Enum
Types of operations that can be performed.
Each operation type corresponds to a specific API endpoint action.