Skip to content

Commit 22e65ac

Browse files
committed
Refactor service flow diagram and update subscription logic for time capability handling
1 parent e3b526a commit 22e65ac

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

docs/specs/time.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,21 @@ flowchart TD
4646
St[Start] --> B(Publish status: starting)
4747
B --> C(Subscribe to cap/time/+/meta/source)
4848
C --> D(Publish status: running)
49-
D --> E{Wait for first time capability meta message or context done}
50-
E -->|context done| Z[Publish status: stopped]
49+
D --> E{Wait for first time capability meta message or scope done}
50+
E -->|scope done| Z[Publish status: stopped]
5151
E -->|first capability meta received| F(Extract uuid from meta topic)
52-
F --> G(Subscribe to cap/time/uuid/state/synced)
53-
G --> H(Consume retained state and apply sync state)
54-
H --> I(Subscribe to cap/time/uuid/event/synced)
55-
I --> J(Subscribe to cap/time/uuid/event/unsynced)
56-
J --> K{Wait for state, synced event, unsynced event, or context done}
52+
F --> G(Subscribe to cap/time/uuid/state/synced\ncap/time/uuid/event/synced\ncap/time/uuid/event/unsynced)
53+
G --> H(Read single retained state message and apply sync state)
54+
H --> H2(Unsubscribe from state/synced)
55+
H2 --> K{Wait for synced event, unsynced event, or scope done}
5756
K -->|synced event| L(Apply synced: retain svc/time/synced=true, emit transition event)
5857
L --> K
5958
K -->|unsynced event| M(Apply unsynced: retain svc/time/synced=false, emit transition event)
6059
M --> K
61-
K -->|state update| N(Apply state payload synced bool)
62-
N --> K
63-
K -->|context done| Z
60+
K -->|scope done| Z
6461
```
6562

66-
The retained `{'cap', 'time', <uuid>, 'state', 'synced'}` payload is consumed immediately after subscription to initialise sync state before any events arrive.
63+
All three subscriptions are created before any message is read, so no events are lost during initialisation. The retained `{'cap', 'time', <uuid>, 'state', 'synced'}` payload is consumed as a one-shot read to bootstrap sync state, then the state subscription is dropped. Ongoing sync state changes are tracked exclusively through the `event/synced` and `event/unsynced` transition topics.
6764

6865
With the new fibers alarm API, the service calls:
6966
- `alarm.set_time_source(fibers.utils.time.realtime)` on first synced state

0 commit comments

Comments
 (0)