tokio-rs / turmoil

Add hardship to your tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support holding messages after send

mcches opened this issue · comments

Is your feature request related to a problem? Please describe.
No. This is new functionality.

Describe the solution you'd like
During the simulation I'd like to place a "hold" on the link between two hosts. Any messages sent will remain in the queue while the "hold" is active. At a later time I'd like to remove the "hold", which allows delivery for the queued messages.

This is useful for tests that need to control the ordering of events across multiple hosts.

Seems like a good feature 👍

Do you think it's better to hold the messages on the link or in the host? The former seems closer to reality, but requires duplication of the inbox type. I'm inclined towards buffering on the link, but I do the value in simplicity too:

// host.rs
    /// Messages in-flight to the host. Some of these may still be "on the
    /// network".
    inbox: IndexMap<SocketAddr, VecDeque<Envelope>>,

I was considering adding a "hold" token for any messages added to the queue. The delivery logic can inspect both delivery time and if the "hold" is present.