lib/cargo.js
// upload multiple local uncommits to clickhouse
upload multiple local uncommits to clickhouse
upload multiple local uncommits to clickhouse
async uploadLocalUncommitsToClickhouse(filenamList) {
      var filepath, j, len, proc;
      debuglog("[uploadLocalUncommitsToClickhouse] filenamList:", filenamList && filenamList.length);
      if (!(Array.isArray(filenamList) && filenamList.length > 0)) {
        return;
      }
      proc = (resolve, reject) => {
        var req, streams;
        req = this.vehicle.request(this.httpPostOptions, (res) => {
          if (!(res && res.statusCode === 200)) {
            reject(new Error(`ClickHouse server response statusCode:${res && res.statusCode}`));
            return;
          }
          debuglog(`[uploadLocalUncommitsToClickhouse] SUCCESS uploaded ${filenamList.length} uncommits, x-clickhouse-query-id:`, res.headers && res.headers['x-clickhouse-query-id'], ", x-clickhouse-summary:", res.headers && res.headers['x-clickhouse-summary']);
          resolve(res);
        });
        req.on('error', function(err) {
          debuglog("[uploadLocalUncommitsToClickhouse : on err:]", err);
          reject(err);
        });
        req.on('timeout', function() {
          debuglog("[uploadLocalUncommitsToClickhouse : on timeout]");
          req.destroy(new Error('request timeout'));
        });
        req.write(this.statement);
        streams = filenamList.map(function(filepath) {
          return fs.createReadStream(filepath);
        });
        new MultiStream(streams).pipe(req);
      };
      await new Promise(proc);
      for (j = 0, len = filenamList.length; j < len; j++) {
        filepath = filenamList[j];
        debuglog("[uploadLocalUncommitsToClickhouse] clean local commit:", path.basename(filepath));
        await fsAsync.unlink(filepath); 
      }
    }
async uploadLocalUncommitsToClickhouse ( filenamList ) { var filepath , j , len , proc ; debuglog ( "[uploadLocalUncommitsToClickhouse] filenamList:" , filenamList && filenamList . length ) ; if ( ! ( Array . isArray ( filenamList ) && filenamList . length > 0 ) ) { return ; } proc = ( resolve , reject ) => { var req , streams ; req = this . vehicle . request ( this . httpPostOptions , ( res ) => { if ( ! ( res && res . statusCode === 200 ) ) { reject ( new Error ( ` ${ res && res . statusCode } ` ) ) ; return ; } debuglog ( ` ${ filenamList . length } ` , res . headers && res . headers [ 'x-clickhouse-query-id' ] , ", x-clickhouse-summary:" , res . headers && res . headers [ 'x-clickhouse-summary' ] ) ; resolve ( res ) ; } ) ; req . on ( 'error' , function ( err ) { debuglog ( "[uploadLocalUncommitsToClickhouse : on err:]" , err ) ; reject ( err ) ; } ) ; req . on ( 'timeout' , function ( ) { debuglog ( "[uploadLocalUncommitsToClickhouse : on timeout]" ) ; req . destroy ( new Error ( 'request timeout' ) ) ; } ) ; req . write ( this . statement ) ; streams = filenamList . map ( function ( filepath ) { return fs . createReadStream ( filepath ) ; } ) ; new MultiStream ( streams ) . pipe ( req ) ; } ; await new Promise ( proc ) ; for ( j = 0 , len = filenamList . length ; j < len ; j ++ ) { filepath = filenamList [ j ] ; debuglog ( "[uploadLocalUncommitsToClickhouse] clean local commit:" , path . basename ( filepath ) ) ; await fsAsync . unlink ( filepath ) ; } }
upload multiple local uncommits to clickhouse
upload multiple local uncommits to clickhouse
//for filepath in filenamList //try //debuglog "[uploadLocalUncommitsToClickhouse] uploading:", filepath //srcStream = fs.createReadStream(filepath) //srcStream.pipe(req) //catch err //reject(err) //return // remove successfully committed local files