pub struct PoolRegistry {
pub sessions: Vec<PoolSessionEntry>,
}Expand description
In-memory view of registry.json.
This struct must always be loaded from and saved to disk within a
single advisory-lock region (see with_registry_lock). Do not hold
a PoolRegistry value across lock boundaries.
§Crux: registry.json is the persistent source of truth
MCP processes must not rely on any in-memory state to discover live
workers after a restart. Every mutation path must call save before
dropping the lock.
Fields§
§sessions: Vec<PoolSessionEntry>All currently-registered worker sessions.
Implementations§
Source§impl PoolRegistry
impl PoolRegistry
Sourcepub fn load_or_default(path: &Path) -> Result<Self, PoolError>
pub fn load_or_default(path: &Path) -> Result<Self, PoolError>
Load registry.json from disk, returning an empty registry if the
file does not exist.
§Arguments
path— absolute path toregistry.json.
§Returns
Ok(PoolRegistry) — either the parsed on-disk state or an empty
registry when the file is absent.
§Errors
Returns PoolError::RegistryCorrupted(reason) if the file exists but
cannot be parsed as valid JSON. Never falls back to an empty
registry on parse failure — callers must handle the error explicitly
and propagate it to the MCP wire layer.
§Concurrency
This is a synchronous file read. The caller must hold the advisory
fs4::fs_std::FileExt::lock_exclusive on registry.lock before
calling this method to prevent concurrent read-modify-write races
between multiple MCP processes.
Sourcepub fn save(&self, path: &Path) -> Result<(), PoolError>
pub fn save(&self, path: &Path) -> Result<(), PoolError>
Atomically persist the registry to registry.json via
tempfile::NamedTempFile::persist (POSIX rename(2)).
§Arguments
path— absolute path toregistry.json.
§Returns
Ok(()) on success.
§Errors
Returns PoolError::RegistryCorrupted if parent-directory creation,
serialization, temp-file creation/write/fsync, or the atomic rename
fails.
§Atomicity
NamedTempFile::persist is atomic on modern Linux filesystems and
macOS. It is not guaranteed atomic on all platforms.
§Concurrency
Callers must hold the advisory fs4::fs_std::FileExt::lock_exclusive
on registry.lock for the entire read-modify-write cycle
(load → mutate → save) to prevent last-writer-wins data loss when
multiple MCP processes write concurrently.
Sourcepub fn scan_and_gc(&mut self) -> Result<Vec<PoolSessionEntry>, PoolError>
pub fn scan_and_gc(&mut self) -> Result<Vec<PoolSessionEntry>, PoolError>
Scan all registered sessions and remove entries whose worker process is no longer alive, returning the surviving (live) entries.
Liveness is tested with kill(pid, 0) (POSIX signal 0 — does not
send a signal, only checks whether the process exists). An ESRCH
return value means the process does not exist and the entry is pruned.
§Arguments
None — operates on &mut self in place.
§Returns
Ok(Vec<PoolSessionEntry>) — the subset of sessions that survived GC
(i.e. whose worker process is still alive).
§Errors
Currently infallible on POSIX; the Result wrapper is kept for future
extension.
§Platform support
On non-Unix targets the liveness check is omitted and all entries are assumed live (conservative).
Sourcepub fn add(&mut self, entry: PoolSessionEntry)
pub fn add(&mut self, entry: PoolSessionEntry)
Trait Implementations§
Source§impl Clone for PoolRegistry
impl Clone for PoolRegistry
Source§fn clone(&self) -> PoolRegistry
fn clone(&self) -> PoolRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PoolRegistry
impl Debug for PoolRegistry
Source§impl Default for PoolRegistry
impl Default for PoolRegistry
Source§fn default() -> PoolRegistry
fn default() -> PoolRegistry
Source§impl<'de> Deserialize<'de> for PoolRegistry
impl<'de> Deserialize<'de> for PoolRegistry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for PoolRegistry
impl PartialEq for PoolRegistry
Source§fn eq(&self, other: &PoolRegistry) -> bool
fn eq(&self, other: &PoolRegistry) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for PoolRegistry
impl Serialize for PoolRegistry
impl StructuralPartialEq for PoolRegistry
Auto Trait Implementations§
impl Freeze for PoolRegistry
impl RefUnwindSafe for PoolRegistry
impl Send for PoolRegistry
impl Sync for PoolRegistry
impl Unpin for PoolRegistry
impl UnsafeUnpin for PoolRegistry
impl UnwindSafe for PoolRegistry
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 moreimpl<T> MaybeSend for Twhere
T: Send,
impl<T> Scalar for T
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.