-
Notifications
You must be signed in to change notification settings - Fork 3
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
165 dev stale gathering detection #175
base: development
Are you sure you want to change the base?
Conversation
@@ -97,6 +97,8 @@ pub struct Scheduler<A: ActorState> { | |||
recv: SelectAll<ActorStream<A>>, | |||
queue: FuturesUnordered<Pin<Box<dyn 'static + Send + Future<Output = A::Message>>>>, | |||
tasks: FuturesUnordered<Pin<Box<dyn 'static + Send + Future<Output = ()>>>>, | |||
should_terminate: bool, | |||
sender: UnboundedSender<A::Message>, |
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.
I missed this during the peer programming. We might not want a regular sender here. Instead, we might want a downgraded sender.
Imagine we drop all clients to a given actor such that the only way to get a new client is from the scheduler. This means that the actor can't (currently) receive any messages from its primary channel and could be considered dead. However, the channel is not considered closed because the scheduler holds a sender. This could impede otherwise desired cleanup.
I don't think there needs to be a change from this PR, but I wanted to note this for future efforts.
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.
I will downgrade this along with the tests I write on sunday.
0053c64
to
8cf0386
Compare
Progress on the registration page.
a711224
to
7e7eb97
Compare
Persist, | ||
/// Destroy a gathering when the gathering decides that it should be terminated | ||
DestroyGathering(TournamentId, OneshotSender<()>), |
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.
This is very minor, but did you consider using a non-unit, zero-sized type? Basically, a type that is functionally identical to a unit but conveys meaning in its name, say pub struct Completed
.
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.
No I didn't. I am not very familiar with the benefits of that. If there is a resource you can share I'd love to look into it.
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.
The only benefit is that it's easier to understand. At runtime, there is no difference between a struct Completed;
and a ()
. However, seeing OneshotSender<Completed>
makes it easier to remember why you need a sender at all. I bring this up only because, while reviewing this, it took me a little while to remember the reasoning for why we were sending a unit back.
@@ -1,15 +1,16 @@ | |||
use std::collections::HashMap; | |||
use std::{collections::HashMap, ops::Add}; |
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.
Why was std::ops::Add
imported?
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.
My ide recommended importing Add
, because calculating the next check time requires adding a Duration
to an Instant
.
fn get_last_message_checked_at(&self) -> Instant {
self.last_message_processed_at
.add(Duration::from_secs(24 * 60 * 60))
}
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.
Ah, gotcha. You should be able to avoid that in the future by just using the +
operator.
fn get_last_message_checked_at(&self) -> Instant {
self.last_message_processed_at + Duration::from_secs(24 * 60 * 60)
}
d6da8e7
to
cdc8837
Compare
e393898
to
bf0eac7
Compare
No description provided.