pub fn new(
        req: BackupRequest,
        resp: UnboundedSender<BackupResponse>,
    ) -> Result<(Task, Arc<AtomicBool>)> {
        let cancel = Arc::new(AtomicBool::new(false));

        let speed_limit = req.get_rate_limit();
        let limiter = Limiter::new(if speed_limit > 0 {
            speed_limit as f64
        } else {
            INFINITY
        });
        let cf = name_to_cf(req.get_cf()).ok_or_else(|| crate::Error::InvalidCf {
            cf: req.get_cf().to_owned(),
        })?;

        // Check storage backend eagerly.
        create_storage(req.get_storage_backend())?;

        let task = Task {
            request: Request {
                start_key: req.get_start_key().to_owned(),
                end_key: req.get_end_key().to_owned(),
                start_ts: req.get_start_version().into(),
                end_ts: req.get_end_version().into(),
                backend: req.get_storage_backend().clone(),
                limiter,
                cancel: cancel.clone(),
                is_raw_kv: req.get_is_raw_kv(),
                cf,
                compression_type: req.get_compression_type(),
                compression_level: req.get_compression_level(),
            },
            resp,
        };
        Ok((task, cancel))
    }
/// Create a backup task based on the given backup request.
Create a backup task based on the given backup request.
Create a backup task based on the given backup request .
pub fn new(
        req: BackupRequest,
        resp: UnboundedSender<BackupResponse>,
    ) -> Result<(Task, Arc<AtomicBool>)> {
        let cancel = Arc::new(AtomicBool::new(false));
        let speed_limit = req.get_rate_limit();
        let limiter = Limiter::new(if speed_limit > 0 {
            speed_limit as f64
        } else {
            INFINITY
        });
        let cf = name_to_cf(req.get_cf()).ok_or_else(|| crate::Error::InvalidCf {
            cf: req.get_cf().to_owned(),
        })?;
        // Check storage backend eagerly.
        create_storage(req.get_storage_backend())?;
        let task = Task {
            request: Request {
                start_key: req.get_start_key().to_owned(),
                end_key: req.get_end_key().to_owned(),
                start_ts: req.get_start_version().into(),
                end_ts: req.get_end_version().into(),
                backend: req.get_storage_backend().clone(),
                limiter,
                cancel: cancel.clone(),
                is_raw_kv: req.get_is_raw_kv(),
                cf,
                compression_type: req.get_compression_type(),
                compression_level: req.get_compression_level(),
            },
            resp,
        };
        Ok((task, cancel))
    }
pub fn new ( req : BackupRequest , resp : UnboundedSender < BackupResponse > , ) -> Result < ( Task , Arc < AtomicBool > ) > { let cancel = Arc :: new ( AtomicBool :: new ( false ) ) ; let speed_limit = req . get_rate_limit ( ) ; let limiter = Limiter :: new ( if speed_limit > 0 { speed_limit as f64 } else { INFINITY } ) ; let cf = name_to_cf ( req . get_cf ( ) ) . ok_or_else ( | | crate :: Error :: InvalidCf { cf : req . get_cf ( ) . to_owned ( ) , } ) ? ; // Check storage backend eagerly. create_storage ( req . get_storage_backend ( ) ) ? ; let task = Task { request : Request { start_key : req . get_start_key ( ) . to_owned ( ) , end_key : req . get_end_key ( ) . to_owned ( ) , start_ts : req . get_start_version ( ) . into ( ) , end_ts : req . get_end_version ( ) . into ( ) , backend : req . get_storage_backend ( ) . clone ( ) , limiter , cancel : cancel . clone ( ) , is_raw_kv : req . get_is_raw_kv ( ) , cf , compression_type : req . get_compression_type ( ) , compression_level : req . get_compression_level ( ) , } , resp , } ; Ok ( ( task , cancel ) ) }
Create a backup task based on the given backup request.
Create a backup task based on the given backup request .
req
BackupRequest
resp
UnboundedSender<BackupResponse>