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
//! Saga context for accessing server resources during event processing.
//!
//! Sagas react to events and emit **commands** — never events. The emitted
//! `SagaCommand`s are executed by the server against a `CommandContext`, which
//! is where any state mutation happens. So the [`SagaContext`] a saga receives
//! is a minimal *read* context: server identity and the store registry, enough
//! to decide which commands to emit.
//!
//! # Example
//!
//! ```rust,no_run
//! use myko::event::MEvent;
//! use myko::saga::SagaContext;
//!
//! fn is_ours(event: &MEvent, ctx: &SagaContext) -> bool {
//! // Only react to events this server originated.
//! event.source_id.as_deref() == Some(&ctx.host_id().to_string())
//! }
//! ```
use Arc;
use Uuid;
use crateStoreRegistry;
/// Context provided to sagas during event processing.
///
/// A saga's job is to react to events and emit commands (executed later against
/// a `CommandContext`), so this is a read-only context — server identity plus
/// the store registry to decide which commands to emit. It deliberately carries
/// no way to emit events or mutate state directly.