Ghamza-Jd / jarust

A janus client SDK in Rust 🦀
Apache License 2.0
8 stars 3 forks source link

feat/await map #58

Closed Ghamza-Jd closed 7 months ago

Ghamza-Jd commented 7 months ago

Description

The Response and the ACK are unorganized in terms of what comes first when to communicate an ACK should be polled, and when to ignore. This leads to a problem while using a channel, if we send a fire and forget message (which we'll not poll ack), and then send a send_waiton_ack (which will poll the ack) it will poll the wrong ack, since channels are a queue.

To solve this issue, I've introduced a new AwaitMap data structure. On one end, we can insert and on the other end, we can get the inserted data. If we're getting and the data is not available, the task will wait until the data is available, similar to mpsc::Recieve or any other async channel.

Send the events will remain on the channel, as events are expected to be ordered the same way we received them.

Other notes

Improvements

Ghamza-Jd commented 7 months ago

In the future we may move the napmap to its own repo