pub struct EntityReaper { /* private fields */ }Expand description
Background task that periodically scans entity managers for idle instances and removes them.
The check interval dynamically adapts to the shortest registered idle time,
floored at 5 seconds, matching the TS entityReaper.ts behavior:
currentResolution = max(min(currentResolution, maxIdleTime), 5000).
Implementations§
Source§impl EntityReaper
impl EntityReaper
Sourcepub fn new(cancel: CancellationToken) -> Self
pub fn new(cancel: CancellationToken) -> Self
Create a new entity reaper.
Sourcepub async fn register(&self, manager: Arc<EntityManager>, max_idle: Duration)
pub async fn register(&self, manager: Arc<EntityManager>, max_idle: Duration)
Register an entity manager to be reaped with the given max idle duration.
Updates the reaper check interval to max(min(current, max_idle), 5s),
matching the TS entityReaper.ts:28 behavior.
Sourcepub async fn run(&self)
pub async fn run(&self)
Run the reaper loop. This blocks until the cancellation token is cancelled.
The reaper waits until the first entity type is registered, then periodically checks all registered managers at the dynamically-computed interval. The interval adapts to the shortest registered idle time, floored at 5 seconds.
Sourcepub fn current_resolution(&self) -> Duration
pub fn current_resolution(&self) -> Duration
Get the current reaper check interval.
Sourcepub async fn reap_all(&self) -> usize
pub async fn reap_all(&self) -> usize
Perform a single reap pass across all registered managers.
Sourcepub async fn manager_count(&self) -> usize
pub async fn manager_count(&self) -> usize
Get the number of registered managers.
Auto Trait Implementations§
impl !Freeze for EntityReaper
impl !RefUnwindSafe for EntityReaper
impl Send for EntityReaper
impl Sync for EntityReaper
impl Unpin for EntityReaper
impl UnsafeUnpin for EntityReaper
impl !UnwindSafe for EntityReaper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request