Initial commit of integrated agent system
This commit is contained in:
35
backend/process/registry.py
Normal file
35
backend/process/registry.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Registry for managing supervised process metadata."""
|
||||
|
||||
from threading import Lock
|
||||
from typing import Dict, Iterable, Optional
|
||||
|
||||
from .models import ProcessRun
|
||||
|
||||
|
||||
class RunRegistry:
|
||||
"""In-memory registry for tracked process runs."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self._runs: Dict[str, ProcessRun] = {}
|
||||
self._lock = Lock()
|
||||
|
||||
def add(self, run: ProcessRun) -> None:
|
||||
with self._lock:
|
||||
self._runs[run.run_id] = run
|
||||
|
||||
def get(self, run_id: str) -> Optional[ProcessRun]:
|
||||
with self._lock:
|
||||
return self._runs.get(run_id)
|
||||
|
||||
def list(self) -> Iterable[ProcessRun]:
|
||||
with self._lock:
|
||||
return list(self._runs.values())
|
||||
|
||||
def update(self, run: ProcessRun) -> None:
|
||||
with self._lock:
|
||||
self._runs[run.run_id] = run
|
||||
|
||||
def remove(self, run_id: str) -> None:
|
||||
with self._lock:
|
||||
self._runs.pop(run_id, None)
|
||||
Reference in New Issue
Block a user