-
Notifications
You must be signed in to change notification settings - Fork 98
impl(pubsub): lease loop #4120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl(pubsub): lease loop #4120
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4120 +/- ##
==========================================
- Coverage 94.81% 94.77% -0.04%
==========================================
Files 182 183 +1
Lines 6887 6911 +24
==========================================
+ Hits 6530 6550 +20
- Misses 357 361 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| use tokio::task::JoinHandle; | ||
| use tokio_util::sync::CancellationToken; | ||
|
|
||
| /// A convenience struct that groups the components of the lease loop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: all these comments should end with periods.
Comments should usually be complete sentences. Start with a capital letter, end with a period (.). - https://doc.rust-lang.org/stable/style-guide/#comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
5a1f25d to
3ad6205
Compare
Part of the work for #3957
Add a lease loop. The loop runs on end, performing any of the following actions:
I combined these things into a struct, but I may change my mind later.
On testing...
TIL:
mock.checkpoint(). It means check all the expectations at this exact moment.I found it easiest to use an
Arc<Mutex<Mock>>which allowed me to give the mock to the lease loop AND set expectations on the mock outside of the lease loop.I also tried to recover the time at which events happen from within the mock expectations, but decided that was more complicated.
Because
tokio::testis single threaded (if you want tostart_paused = true), I found that I needed to yield the current execution so tokio would actually launch the lease loop. Otherwise it would not launch the lease loop until the first.awaitpoint, and the timing was all messed up.