init commit
This commit is contained in:
21
nimbus/daemon/status_reporter.py
Normal file
21
nimbus/daemon/status_reporter.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import threading
|
||||
import time
|
||||
|
||||
from .status import ComponentStatus, StatusInfo
|
||||
from .status_monitor import StatusMonitor
|
||||
|
||||
|
||||
class StatusReporter:
|
||||
def __init__(self, component_id: str):
|
||||
self.component_id = component_id
|
||||
self._status_info = StatusInfo(component_id, ComponentStatus.IDLE)
|
||||
self._lock = threading.Lock()
|
||||
|
||||
def update_status(self, status: ComponentStatus):
|
||||
with self._lock:
|
||||
self._status_info = StatusInfo(component_id=self.component_id, status=status, last_update=time.time())
|
||||
StatusMonitor.get_instance().register_update(self._status_info)
|
||||
|
||||
def get_status(self) -> StatusInfo:
|
||||
with self._lock:
|
||||
return self._status_info
|
||||
Reference in New Issue
Block a user