Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This rewrite consists of both a migration to an asynchronous model and a migration to the proposed RabbitMQ architecture, because the
lapin
crate is one of the most mature AMQP client crates for Rust, except it's asynchronousHere is the gist of the new structure:
This task will continuously refresh the access token, this makes it so that each task doesn't have to send a request, check if it's authentication failed, then re-send it. Now, all operations can simply assume the authentication is update to date. This task will refresh the access tokens 10 seconds early just to have some built-in tolerance.
dragonfly-client-rs/src/main.rs
Lines 109 to 119 in 510e63a
This task listens on the exclusive queue that will get rule updates. It doesn't really matter what comes over this queue, since it will be discarded. Each client will establish it's own, exclusive queue and bind it to the
rule_updates
fanout exchange. Mainframe will dispatch a message to all on this queue whenever the rules are updated. Clients will then have to fetch the new rules from/rules
, compile the rules, and update their local state.dragonfly-client-rs/src/main.rs
Lines 121 to 131 in 510e63a
This loop listens on the
jobs
queue for incoming jobs, and creates a task for each of them.dragonfly-client-rs/src/main.rs
Lines 133 to 151 in 510e63a