1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! The [`ThreadObserver`] trait: how embeddings observe thread execution.
use async_trait;
use ThreadId;
use RefCell;
use ;
/// Observes a thread's execution and commits any platform state derived from
/// it.
///
/// The step pipeline calls these methods at exact points in its execution —
/// there is no intermediate channel or forwarding task — which gives two
/// guarantees:
///
/// - **Ordering**: [`on_event`](Self::on_event) is invoked synchronously at
/// the moment the event is emitted, in the same executor poll that produced
/// it. An embedding that broadcasts events to subscribers and answers
/// attach requests from [`on_subscribe`](Self::on_subscribe) therefore gets
/// exactly-once delivery for free: an event is either already reflected in
/// the [`ReplaySnapshot`] a new subscriber receives, or it is broadcast to
/// that subscriber afterwards — never both, never neither.
/// - **Durability**: stateful events are emitted after the runtime has awaited
/// their corresponding [`StateStore`](crate::traits::StateStore) transition.
///
/// Implementations that need mutable state should use interior mutability
/// (`RefCell`); the methods take `&self` so the runtime can hold shared
/// references across a step.
/// An observer that buffers all events in memory, tagged with the thread that
/// emitted them. Useful for step-mode embeddings (e.g. a Lambda handler) that
/// inspect the events after the slice completes — a slice's batch may span
/// multiple threads.