Skip to main content

Mountain/Vine/Client/
DisconnectFromSideCar.rs

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