pub struct OctopipesServer { /* private fields */ }
Expand description
§OctopipesServer
OctopipesServer
is a container for an Octopipes Server
Implementations§
Source§impl OctopipesServer
impl OctopipesServer
Sourcepub fn new(
version: OctopipesProtocolVersion,
cap_pipe: String,
client_folder: String,
) -> OctopipesServer
pub fn new( version: OctopipesProtocolVersion, cap_pipe: String, client_folder: String, ) -> OctopipesServer
§new
new
instances a new OctopipesServer
Sourcepub fn stop_server(&mut self) -> Result<(), OctopipesServerError>
pub fn stop_server(&mut self) -> Result<(), OctopipesServerError>
§stop_server
stop_server
stops the octopipes server (workers and cap listener)
Sourcepub fn start_cap_listener(&mut self) -> Result<(), OctopipesServerError>
pub fn start_cap_listener(&mut self) -> Result<(), OctopipesServerError>
§start_cap_listener
start_cap_listener
Start CAP listener thread
Sourcepub fn stop_cap_listener(&mut self) -> Result<(), OctopipesServerError>
pub fn stop_cap_listener(&mut self) -> Result<(), OctopipesServerError>
§stop_cap_listener
stop_cap_listener
stops the server cap listener thread
Sourcepub fn start_worker(
&mut self,
client: String,
subscriptions: Vec<String>,
cli_tx_pipe: String,
cli_rx_pipe: String,
) -> Result<(), OctopipesServerError>
pub fn start_worker( &mut self, client: String, subscriptions: Vec<String>, cli_tx_pipe: String, cli_rx_pipe: String, ) -> Result<(), OctopipesServerError>
§start_worker
start_worker
add and starts a new worker for the Octopipes Server. The server must be in Running state
Sourcepub fn stop_worker(
&mut self,
client: &String,
) -> Result<(), OctopipesServerError>
pub fn stop_worker( &mut self, client: &String, ) -> Result<(), OctopipesServerError>
§stop_worker
stop_worker
stops a running worker for the Octopipes Server. The server must be in Running state
Sourcepub fn dispatch_message(
&self,
message: &OctopipesMessage,
) -> Result<(), (Option<String>, OctopipesServerError)>
pub fn dispatch_message( &self, message: &OctopipesMessage, ) -> Result<(), (Option<String>, OctopipesServerError)>
§dispatch_message
dispatch_message
Dispatch a message to subscribed nodes. Returns error with the error type and the client id of the worker associated which returned an error
Sourcepub fn process_cap_once(&mut self) -> Result<usize, OctopipesServerError>
pub fn process_cap_once(&mut self) -> Result<usize, OctopipesServerError>
§process_cap_once
process_cap_once
Reads up to one message from the CAP receiver and process it.
When Ok, returns the amount of messages processed (0/1), otherwise an Error
Sourcepub fn process_cap_all(&mut self) -> Result<usize, OctopipesServerError>
pub fn process_cap_all(&mut self) -> Result<usize, OctopipesServerError>
§process_cap_all
process_cap_all
Reads all the available messages on the CAP until no one is available.
When Ok, returns the amount of messages processed, otherwise Error
Sourcepub fn manage_cap_message(
&mut self,
message: &OctopipesMessage,
) -> Result<OctopipesCapMessage, OctopipesServerError>
pub fn manage_cap_message( &mut self, message: &OctopipesMessage, ) -> Result<OctopipesCapMessage, OctopipesServerError>
§manage_cap_message
manage_cap_message
Takes a Message from CAP and based on its type perform an action to the server.
If necessary it also responds to the client through the CAP.
(e.g. in case of subscription it will send an assignment back)
Sourcepub fn process_first(&self) -> Result<usize, (String, OctopipesServerError)>
pub fn process_first(&self) -> Result<usize, (String, OctopipesServerError)>
§process_first
process_first
Find the first Worker which has an available message to process and dispatch it
When OK is returned, the number of processed workers is returned
If no worker has a message to process, the function will just return Ok
If an error was returned during the process, the function will return Error((client_id, Error))
Sourcepub fn process_once(&self) -> Result<usize, (String, OctopipesServerError)>
pub fn process_once(&self) -> Result<usize, (String, OctopipesServerError)>
§process_once
process_once
For each worker process the first message in its inbox. If the worker has no message it will be just ignored.
When OK is returned, the number of processed workers is returned
If no worker has a message to process, the function will just return Ok
If an error was returned during the process, the function will return Error((client_id, Error))
Sourcepub fn process_all(&self) -> Result<usize, (String, OctopipesServerError)>
pub fn process_all(&self) -> Result<usize, (String, OctopipesServerError)>
§process_once
process_once
For each worker process the first message in its inbox. If the worker has no message it will be just ignored.
Once all the workers have been process the function will restart until all the workers has no more message in their inbox.
When OK is returned, the number of processed workers is returned
If no worker has a message to process, the function will just return Ok
If an error was returned during the process, the function will return Error((client_id, Error))
Sourcepub fn is_subscribed(&self, client: String) -> Option<Instant>
pub fn is_subscribed(&self, client: String) -> Option<Instant>
§is_subscribed
is_subscribed
returns whether a client with a certain ID is subscribed or not
Sourcepub fn get_subscriptions(&self, client: String) -> Option<Vec<String>>
pub fn get_subscriptions(&self, client: String) -> Option<Vec<String>>
§get_subscriptions
get_subscriptions
Get all the subscriptions for a certain client
Sourcepub fn get_clients(&self) -> Vec<String>
pub fn get_clients(&self) -> Vec<String>
§get_clients
get_clients
Get all the clients id subscribed to the server