sos_core/events/
change.rs1use crate::{commit::CommitSpan, events::EventLogType, AccountId};
2use serde::{Deserialize, Serialize};
3use std::sync::OnceLock;
4use tokio::sync::watch;
5
6static CHANGES_FEED: OnceLock<watch::Sender<LocalChangeEvent>> =
7 OnceLock::new();
8
9#[derive(Serialize, Deserialize, Default, Debug, Clone)]
18#[serde(rename_all = "camelCase")]
19pub enum LocalChangeEvent {
20 #[default]
22 Init,
23 AccountCreated(AccountId),
25 AccountModified {
27 account_id: AccountId,
29 log_type: EventLogType,
31 commit_span: CommitSpan,
33 },
34 AccountDeleted(AccountId),
36}
37
38pub fn changes_feed<'a>() -> &'a watch::Sender<LocalChangeEvent> {
40 CHANGES_FEED.get_or_init(|| {
41 let (tx, _) = watch::channel(LocalChangeEvent::default());
42 tx
43 })
44}