askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
exchange_deliver.py · 1.1 KB · 28 lines
| 1 | """system_exchange_deliver -- the daemon's delivery pass over exchange_outbox. |
| 2 | |
| 3 | Declared as a schedule in app-exchange's manifest (every three minutes): every |
| 4 | queued document whose next attempt has come is posted to its partner with a |
| 5 | freshly signed delivery stamp; a verified receipt marks it delivered, a |
| 6 | refusal stops it (`dead`, the attention queue exchange_undelivered), and no |
| 7 | answer schedules the next attempt with exponential backoff |
| 8 | (object_exchange_box.deliver_due). Time-driven, so it belongs to the daemon |
| 9 | (docs/logic-decisions.md #2). Retrying is safe: the receiver stores a |
| 10 | document once by its id, and the call is not paid. |
| 11 | |
| 12 | POST = EVENT: the scheduler calls POST and the dispatcher EVENT (AGENTS.md). |
| 13 | """ |
| 14 | |
| 15 | import object_exchange |
| 16 | import object_exchange_box as box |
| 17 | |
| 18 | |
| 19 | def EVENT(request): |
| 20 | try: |
| 21 | return box.deliver_due(box.base_dir()) |
| 22 | except object_exchange.ExchangeUnavailable as exc: |
| 23 | return {"status": 409, "code": "exchange_unavailable", "error": str(exc)} |
| 24 | except box.Refusal as refusal: |
| 25 | return refusal.answer() |
| 26 | |
| 27 | |
| 28 | POST = EVENT |