-
Notifications
You must be signed in to change notification settings - Fork 0
6 DR 20230809_1
Keywords: architecture, design
Participants: Manuel Hatzl
Default Flow:
- An intermediary event is set at any point during program execution, containing the event-ID and message
- The intermediary event-entry gets a unique UUID, because an event-ID may be set multiple times, but each entry is unique
- Optional: Additional content may be added to the intermediary event-entry
- Once the intermediary event is finalized by going out of scope, or manually using
finalize()
, it is converted to an event, and sent to the event handler usingstd::sync::mpsc::sync_channel
- The event handler receives the event, and forwards the event to all subscribers listening to the event, again using
std::sync::mpsc::sync_channel
, but now one channel per subscriber - Every subscriber receives the event, and may react to it
Capturing Stopped:
- An intermediary event is set at any point during program execution, containing the event-ID and message
- The intermediary event-entry gets a unique UUID, because an event-ID may be set multiple times, but each entry is unique
- Optional: Additional content may be added to the intermediary event-entry
- Once the intermediary event is finalized by going out of scope, or manually using
finalize()
, it is converted to an event - If capturing is stopped, the event is not sent, but available in the thread the event was manually finalized
Global Filter:
Same steps as above, with the addition that the event is only sent to the event handler if the filter allows it.
With sync_channel, it is possible to send events without blocking the sending thread on every send()
, because a send-buffer can be set per channel.
The std library only offers multiple producer single consumer channels for now, but there might be multiple subscribers (consumers) listening for events.
Other crates offering multiple consumer channels, forwarded events to the first consumer that receives the event. This is also not acceptable, because every subscriber must receive the event.
While the indirection might be a bottleneck, the approach makes it possible to stick with std, which reduces the number of dependencies.
The event handler is moved in its own thread, continuously blocking until the next event is received.
while let Ok(event) = handler.recv() {
// forward event to subscriber
}
Caveat: Because recv()
blocks the thread until an event is received, the event handler only reacts to events.
Please create an issue if you found any spelling mistakes.
You may also create an issue if you think the content of this wiki should be improved.
Note: This wiki is managed in its own repository. Any commits made using the edit
button will be overwritten.
Note: Issues for the wiki are handled in the evident repository, but pull requests for the wiki are handled in the evident-wiki repository.
This wiki is MIT licensed, and works together with the evident crate.