fn download(
        &mut self,
        ctx: RpcContext<'_>,
        req: DownloadRequest,
        sink: UnarySink<DownloadResponse>,
    ) {
        if !check_common_name(self.security_mgr.cert_allowed_cn(), &ctx) {
            return;
        }
        let label = "download";
        let timer = Instant::now_coarse();
        let importer = Arc::clone(&self.importer);
        let limiter = self.limiter.clone();
        let sst_writer = <RocksEngine as SstExt>::SstWriterBuilder::new()
            .set_db(&self.engine)
            .set_cf(name_to_cf(req.get_sst().get_cf_name()).unwrap())
            .build(self.importer.get_path(req.get_sst()).to_str().unwrap())
            .unwrap();

        let handle_task = async move {
            // FIXME: download() should be an async fn, to allow BR to cancel
            // a download task.
            // Unfortunately, this currently can't happen because the S3Storage
            // is not Send + Sync. See the documentation of S3Storage for reason.
            let res = importer.download::<RocksEngine>(
                req.get_sst(),
                req.get_storage_backend(),
                req.get_name(),
                req.get_rewrite_rule(),
                limiter,
                sst_writer,
            );
            let mut resp = DownloadResponse::default();
            match res {
                Ok(range) => match range {
                    Some(r) => resp.set_range(r),
                    None => resp.set_is_empty(true),
                },
                Err(e) => resp.set_error(e.into()),
            }
            let resp = Ok(resp);
            send_rpc_response!(resp, sink, label, timer);
        };

        let thread_handle = self.threads.clone();
        let ctx_task = async move {
            thread_handle.spawn_ok(handle_task);
        };
        ctx.spawn(Compat::new(ctx_task.unit_error().boxed()));
    }
/// Downloads the file and performs key-rewrite for later ingesting.
Downloads the file and performs key-rewrite for later ingesting.
Downloads the file and performs key - rewrite for later ingesting .
fn download(
        &mut self,
        ctx: RpcContext<'_>,
        req: DownloadRequest,
        sink: UnarySink<DownloadResponse>,
    ) {
        if !check_common_name(self.security_mgr.cert_allowed_cn(), &ctx) {
            return;
        }
        let label = "download";
        let timer = Instant::now_coarse();
        let importer = Arc::clone(&self.importer);
        let limiter = self.limiter.clone();
        let sst_writer = <RocksEngine as SstExt>::SstWriterBuilder::new()
            .set_db(&self.engine)
            .set_cf(name_to_cf(req.get_sst().get_cf_name()).unwrap())
            .build(self.importer.get_path(req.get_sst()).to_str().unwrap())
            .unwrap();
        let handle_task = async move {
            // FIXME: download() should be an async fn, to allow BR to cancel
            // a download task.
            // Unfortunately, this currently can't happen because the S3Storage
            // is not Send + Sync. See the documentation of S3Storage for reason.
            let res = importer.download::<RocksEngine>(
                req.get_sst(),
                req.get_storage_backend(),
                req.get_name(),
                req.get_rewrite_rule(),
                limiter,
                sst_writer,
            );
            let mut resp = DownloadResponse::default();
            match res {
                Ok(range) => match range {
                    Some(r) => resp.set_range(r),
                    None => resp.set_is_empty(true),
                },
                Err(e) => resp.set_error(e.into()),
            }
            let resp = Ok(resp);
            send_rpc_response!(resp, sink, label, timer);
        };
        let thread_handle = self.threads.clone();
        let ctx_task = async move {
            thread_handle.spawn_ok(handle_task);
        };
        ctx.spawn(Compat::new(ctx_task.unit_error().boxed()));
    }
fn download ( & mut self , ctx : RpcContext < ' _ > , req : DownloadRequest , sink : UnarySink < DownloadResponse > , ) { if ! check_common_name ( self . security_mgr . cert_allowed_cn ( ) , & ctx ) { return ; } let label = " " ; let timer = Instant :: now_coarse ( ) ; let importer = Arc :: clone ( & self . importer ) ; let limiter = self . limiter . clone ( ) ; let sst_writer = < RocksEngine as SstExt > :: SstWriterBuilder :: new ( ) . set_db ( & self . engine ) . set_cf ( name_to_cf ( req . get_sst ( ) . get_cf_name ( ) ) . unwrap ( ) ) . build ( self . importer . get_path ( req . get_sst ( ) ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ; let handle_task = async move { // FIXME: download() should be an async fn, to allow BR to cancel // a download task. // Unfortunately, this currently can't happen because the S3Storage // is not Send + Sync. See the documentation of S3Storage for reason. let res = importer . download :: < RocksEngine > ( req . get_sst ( ) , req . get_storage_backend ( ) , req . get_name ( ) , req . get_rewrite_rule ( ) , limiter , sst_writer , ) ; let mut resp = DownloadResponse :: default ( ) ; match res { Ok ( range ) => match range { Some ( r ) => resp . set_range ( r ) , None => resp . set_is_empty ( true ) , } , Err ( e ) => resp . set_error ( e . into ( ) ) , } let resp = Ok ( resp ) ; send_rpc_response ! ( resp sink label timer ) ; } ; let thread_handle = self . threads . clone ( ) ; let ctx_task = async move { thread_handle . spawn_ok ( handle_task ) ; } ; ctx . spawn ( Compat :: new ( ctx_task . unit_error ( ) . boxed ( ) ) ) ; }
Downloads the file and performs key-rewrite for later ingesting.
Downloads the file and performs key - rewrite for later ingesting .
&mut self
ctx
RpcContext<'_>
req
DownloadRequest
sink
UnarySink<DownloadResponse>