input-output-hk / hermes

🏛️ Hermes is a high-availability blockchain voting database that acts as a distributed storage and event processor for voting events, proposals, and actions.
https://input-output-hk.github.io/hermes
Apache License 2.0
13 stars 2 forks source link

🛠️ [TASK] : Hermes Event completness notification #256

Open Mr-Leshiy opened 2 weeks ago

Mr-Leshiy commented 2 weeks ago

Summary

Implement a mechanism which will allow, for a producer of the Hermes event, to know whether this event was already executed or not. So the event producer's could look like:

let event = SomeEvent::new();
let event_waiter = event.get_waiter();
event::queue::send(event); 
event_waiter.wait();

Description

Potential implementation

  1. Every Event can have an OPTIONAL mpsc queue of depth n attached to it.
  2. The Extension generating the event, if it wants notice that the event is fully processed, creates the mpsc queue, and attaches it to the event.
  3. The Sender then waits on the queue.
  4. The Event queue, dispatches the event, and when the event is fully processed, before its discarded, the event queue posts the event back to the mpsc queue in the event itself (assuming one is defined).
stevenj commented 2 weeks ago

We want the three added functions:

make_waiter() -> Returns the RX handle, sets internally Some(tx_handle).
set_waiter(tx) -> Sets Some(tx_handle) if the mpsc was already created outside.
finished() -> if tx_handle.is_not_none() tx_handle.send(self)
stevenj commented 2 weeks ago

See: https://docs.google.com/presentation/d/1x3NurZOrhfOLbnxjR-yKfEWKUAX2YuCUluLsFxqFspA/edit#slide=id.g241d21583e2_0_15