use crate::RaftTypeConfig;
use crate::errors::ReplicationClosed;
use crate::progress::stream_id::StreamId;
use crate::replication::replicate::Replicate;
use crate::replication::snapshot_transmitter_handle::SnapshotTransmitterHandle;
use crate::type_config::alias::JoinHandleOf;
use crate::type_config::alias::WatchSenderOf;
pub(crate) struct ReplicationHandle<C>
where C: RaftTypeConfig
{
pub(crate) stream_id: StreamId,
pub(crate) replicate_tx: WatchSenderOf<C, Replicate<C>>,
pub(crate) cancel_tx: WatchSenderOf<C, ()>,
pub(crate) join_handle: Option<JoinHandleOf<C, Result<(), ReplicationClosed>>>,
pub(crate) snapshot_transmit_handle: Option<SnapshotTransmitterHandle<C>>,
}
impl<C> ReplicationHandle<C>
where C: RaftTypeConfig
{
pub(crate) fn new(
stream_id: StreamId,
replicate_tx: WatchSenderOf<C, Replicate<C>>,
cancel_tx: WatchSenderOf<C, ()>,
) -> Self {
Self {
stream_id,
join_handle: None,
replicate_tx,
snapshot_transmit_handle: None,
cancel_tx,
}
}
}