Struct sshx_server::state::mesh::StorageMesh
source · pub struct StorageMesh { /* private fields */ }
Expand description
Communication with a distributed mesh of sshx server nodes.
This uses a Redis instance to persist data across restarts, as well as a pub/sub channel to keep be notified of when another node becomes the owner of an active session.
All servers must be accessible to each other through TCP mesh networking, since requests are forwarded to the controller of a given session.
Implementations§
source§impl StorageMesh
impl StorageMesh
sourcepub fn new(redis_url: &str, host: Option<&str>) -> Result<Self>
pub fn new(redis_url: &str, host: Option<&str>) -> Result<Self>
Construct a new storage object from Redis URL.
sourcepub fn host(&self) -> Option<&str>
pub fn host(&self) -> Option<&str>
Returns the hostname of this server, if running in mesh node.
sourcepub async fn get_owner(&self, name: &str) -> Result<Option<String>>
pub async fn get_owner(&self, name: &str) -> Result<Option<String>>
Retrieve the hostname of the owner of a session.
sourcepub async fn get_owner_snapshot(
&self,
name: &str,
) -> Result<(Option<String>, Option<Vec<u8>>)>
pub async fn get_owner_snapshot( &self, name: &str, ) -> Result<(Option<String>, Option<Vec<u8>>)>
Retrieve the owner and snapshot of a session.
sourcepub async fn background_sync(&self, name: &str, session: Arc<Session>)
pub async fn background_sync(&self, name: &str, session: Arc<Session>)
Periodically set the owner and snapshot of a session.
sourcepub async fn mark_closed(&self, name: &str) -> Result<()>
pub async fn mark_closed(&self, name: &str) -> Result<()>
Mark a session as closed, so it will expire and never be accessed again.
sourcepub async fn notify_transfer(&self, name: &str, host: &str) -> Result<()>
pub async fn notify_transfer(&self, name: &str, host: &str) -> Result<()>
Notify a host that a session has been transferred.
sourcepub fn listen_for_transfers(&self) -> impl Stream<Item = String> + Send + '_
pub fn listen_for_transfers(&self) -> impl Stream<Item = String> + Send + '_
Listen for sessions that are transferred away from this host.
Trait Implementations§
source§impl Clone for StorageMesh
impl Clone for StorageMesh
source§fn clone(&self) -> StorageMesh
fn clone(&self) -> StorageMesh
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for StorageMesh
impl !RefUnwindSafe for StorageMesh
impl Send for StorageMesh
impl Sync for StorageMesh
impl Unpin for StorageMesh
impl !UnwindSafe for StorageMesh
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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> 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