Skip to main content

Mountain/Vine/Client/
DisconnectFromSideCar.rs

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