use crate::error::ZmqError;
use crate::message::{FrameBatch, Msg};
use crate::runtime::system_events::ConnectionInteractionModel;
use crate::socket::connection_iface::ISocketConnection;
use crate::socket::patterns::ready_pipe_queue::PipeMessageSender;
use crate::socket::MonitorSender;
#[cfg(feature = "io-uring")]
use crate::Blob;
use std::os::unix::io::RawFd;
use std::sync::Arc;
use fibre::mpmc::{AsyncReceiver, AsyncSender};
use fibre::mpsc::BoundedAsyncReceiver;
use fibre::oneshot;
use tokio::task::Id as TaskId;
#[derive(Debug)]
#[allow(dead_code)]
pub enum Command {
UserBind {
endpoint: String,
reply_tx: oneshot::Sender<Result<(), ZmqError>>,
},
UserConnect {
endpoint: String,
reply_tx: oneshot::Sender<Result<(), ZmqError>>,
},
UserDisconnect {
endpoint: String,
reply_tx: oneshot::Sender<Result<(), ZmqError>>,
},
UserUnbind {
endpoint: String,
reply_tx: oneshot::Sender<Result<(), ZmqError>>,
},
UserSend {
msg: Msg,
},
UserRecv {
reply_tx: oneshot::Sender<Result<Msg, ZmqError>>,
},
UserSetOpt {
option: i32,
value: Vec<u8>,
reply_tx: oneshot::Sender<Result<(), ZmqError>>,
},
UserGetOpt {
option: i32,
reply_tx: oneshot::Sender<Result<Vec<u8>, ZmqError>>,
},
UserMonitor {
monitor_tx: MonitorSender,
reply_tx: oneshot::Sender<Result<(), ZmqError>>,
},
UserClose {
reply_tx: oneshot::Sender<Result<(), ZmqError>>,
},
Stop,
PipeMessageReceived {
pipe_id: usize,
msg: Msg,
},
PipeMessageBatchReceived {
pipe_id: usize,
msgs: FrameBatch,
},
PipeClosedByPeer {
pipe_id: usize,
},
AttachPipe {
rx_from_core: AsyncReceiver<Msg>,
tx_to_core: AsyncSender<Msg>,
pipe_read_id: usize,
pipe_write_id: usize,
},
ScaInitializePipes {
sca_handle_id: usize,
rx_from_core: BoundedAsyncReceiver<FrameBatch>,
core_pipe_read_id_for_incoming_routing: usize,
incoming_pipe_sender: Option<PipeMessageSender>,
},
NewConnectionEstablished {
endpoint_uri: String,
target_endpoint_uri: String,
connection_iface: Option<Arc<dyn ISocketConnection>>,
interaction_model: ConnectionInteractionModel,
managing_actor_task_id: Option<TaskId>,
},
#[cfg(feature = "io-uring")]
UringConnectionEstablished {
endpoint_uri: String,
target_endpoint_uri: String,
connection_iface: Arc<dyn ISocketConnection>,
peer_identity: Option<Blob>,
fd: RawFd,
},
#[cfg(feature = "io-uring")]
UringFdError {
endpoint_uri: String,
error: ZmqError,
},
}
impl Command {
pub fn variant_name(&self) -> &'static str {
match self {
Command::UserBind { .. } => "UserBind",
Command::UserConnect { .. } => "UserConnect",
Command::UserDisconnect { .. } => "UserDisconnect",
Command::UserUnbind { .. } => "UserUnbind",
Command::UserSend { .. } => "UserSend",
Command::UserRecv { .. } => "UserRecv",
Command::UserSetOpt { .. } => "UserSetOpt",
Command::UserGetOpt { .. } => "UserGetOpt",
Command::UserMonitor { .. } => "UserMonitor",
Command::UserClose { .. } => "UserClose",
Command::Stop => "Stop",
Command::PipeMessageReceived { .. } => "PipeMessageReceived",
Command::PipeMessageBatchReceived { .. } => "PipeMessageBatchReceived",
Command::PipeClosedByPeer { .. } => "PipeClosedByPeer",
Command::AttachPipe { .. } => "AttachPipe",
Command::ScaInitializePipes { .. } => "ScaInitializePipes",
Command::NewConnectionEstablished { .. } => "NewConnectionEstablished",
#[cfg(feature = "io-uring")]
Command::UringConnectionEstablished { .. } => "UringConnectionEstablished",
#[cfg(feature = "io-uring")]
Command::UringFdError { .. } => "UringFdError",
}
}
}