Skip to content
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

Open
wants to merge 13 commits into
base: development
Choose a base branch
from

Conversation

akbulutdora
Copy link
Contributor

No description provided.

@akbulutdora akbulutdora linked an issue Oct 15, 2023 that may be closed by this pull request
@akbulutdora akbulutdora changed the base branch from main to account-creation October 15, 2023 18:00
@@ -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>,
Copy link
Member

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.

Copy link
Contributor Author

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.

@TylerBloom TylerBloom force-pushed the 165-dev-stale-gathering-detection branch from a711224 to 7e7eb97 Compare November 6, 2023 02:52
@TylerBloom TylerBloom changed the base branch from account-creation to development November 6, 2023 02:54
squire_sdk/src/server/gathering/hall.rs Show resolved Hide resolved
Persist,
/// Destroy a gathering when the gathering decides that it should be terminated
DestroyGathering(TournamentId, OneshotSender<()>),
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

squire_sdk/src/server/gathering/hall.rs Show resolved Hide resolved
@@ -1,15 +1,16 @@
use std::collections::HashMap;
use std::{collections::HashMap, ops::Add};
Copy link
Member

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?

Copy link
Contributor Author

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))
}

Copy link
Member

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)
}

@TylerBloom TylerBloom force-pushed the development branch 3 times, most recently from e393898 to bf0eac7 Compare December 21, 2023 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Dev]: Stale gathering detection
3 participants