chore: update group active (#743)
* chore: opti logs * chore: update group active logic * chore: fmt
This commit is contained in:
parent
52f33e4d85
commit
1122031735
|
|
@ -523,7 +523,9 @@ impl Subscription {
|
|||
}
|
||||
if let Some(stream_stop_tx) = self.stream_stop_tx.take() {
|
||||
if let Err(err) = stream_stop_tx.send(()).await {
|
||||
warn!("the stream might be already stop, error: {}", err);
|
||||
if cfg!(debug_assertions) {
|
||||
warn!("the stream might be already stop, error: {}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use collab_entity::CollabType;
|
|||
use dashmap::DashMap;
|
||||
use futures_util::{SinkExt, StreamExt};
|
||||
use tokio::sync::{mpsc, RwLock};
|
||||
use tracing::{error, event, info, trace};
|
||||
use tracing::{error, event, trace};
|
||||
use yrs::updates::decoder::Decode;
|
||||
use yrs::updates::encoder::Encode;
|
||||
use yrs::Update;
|
||||
|
|
@ -200,24 +200,7 @@ impl CollabGroup {
|
|||
modified_at.elapsed().as_secs() > 60 * 60
|
||||
} else {
|
||||
let elapsed_secs = modified_at.elapsed().as_secs();
|
||||
if elapsed_secs > self.timeout_secs() {
|
||||
// Mark the group as inactive if it has been inactive for more than 3 hours, even if there are subscribers.
|
||||
// Otherwise, return true only if there are no subscribers.
|
||||
const MAXIMUM_SECS: u64 = 3 * 60 * 60;
|
||||
if elapsed_secs > MAXIMUM_SECS {
|
||||
info!(
|
||||
"Group:{} is inactive for {} seconds, subscribers: {}",
|
||||
self.object_id,
|
||||
modified_at.elapsed().as_secs(),
|
||||
self.subscribers.len()
|
||||
);
|
||||
true
|
||||
} else {
|
||||
self.subscribers.is_empty()
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
elapsed_secs > self.timeout_secs() && self.subscribers.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue