Skip to main content

Vine/Client/
DisconnectFromSideCar.rs

1//! Disconnect from a sidecar process. Removes the entry from both the
2//! connection pool and the metadata tracker.
3
4use crate::{
5	Client::Shared::{CONNECTION_METADATA, SIDECAR_CLIENTS},
6	Error::VineError,
7	dev_log,
8};
9
10pub fn Fn(SideCarIdentifier:String) -> Result<(), VineError> {
11	let mut Pool = SIDECAR_CLIENTS.lock();
12
13	if Pool.remove(&SideCarIdentifier).is_some() {
14		CONNECTION_METADATA.lock().remove(&SideCarIdentifier);
15
16		dev_log!("grpc", "[VineClient] Disconnected from sidecar '{}'", SideCarIdentifier);
17
18		Ok(())
19	} else {
20		Err(VineError::ClientNotConnected(SideCarIdentifier))
21	}
22}