Add event-driven reporting and durable failure recovery hooks
This commit is contained in:
@@ -260,6 +260,7 @@ def work(cfg, once=False):
|
||||
if state.get('inflight'):
|
||||
raise RuntimeError('Previous execution was interrupted; inspect its thread and side effects before explicit retry')
|
||||
response = client.call('/api/worker/claim', {'worker_id': worker_id, 'session_id': session_id, 'lease_seconds': 120})
|
||||
atomic_json(state_path.parent/'worker-health.json',{'status':'ok','updated':time.time()})
|
||||
if response.get('needs_reconciliation'):
|
||||
raise RuntimeError('Server session requires reconciliation; no message will be executed')
|
||||
message = response.get('message')
|
||||
@@ -269,6 +270,7 @@ def work(cfg, once=False):
|
||||
state['inflight'] = {**lease, 'started_at': datetime.now(timezone.utc).isoformat()}
|
||||
atomic_json(state_path, state)
|
||||
def renew():
|
||||
atomic_json(state_path.parent/'worker-health.json',{'status':'ok','updated':time.time()})
|
||||
try:
|
||||
client.call('/api/worker/renew', {**lease, 'lease_seconds': 120})
|
||||
except APIError as exc:
|
||||
|
||||
Reference in New Issue
Block a user