Compare commits

...

1 Commits

Author SHA1 Message Date
vrancurel 870f0721bc improvement: parallelize get bucket and get object 2020-02-06 11:18:50 -08:00
1 changed files with 37 additions and 22 deletions

View File

@ -250,32 +250,47 @@ class MongoClientInterface {
}
getBucketAndObject(bucketName, objName, params, log, cb) {
return async.parallel({
bucket: callback => {
this.getBucketAttributes(bucketName, log, (err, bucket) => {
if (err) {
log.error(
'getBucketAttributes: error getting bucket attributes',
'getBucketAndObject: error getting bucket attrs',
{ error: err.message });
return cb(err);
return callback(err);
}
return callback(null, bucket);
});
},
obj: callback => {
this.getObject(bucketName, objName, params, log, (err, obj) => {
if (err) {
if (err === errors.NoSuchKey) {
return callback(null, null);
}
log.error('getBucketAndObject: error getting object',
{ error: err.message });
return callback(err);
}
return callback(null, obj);
});
},
}, (err, results) => {
if (err) {
return cb(errors.InternalError);
}
const { bucket, obj } = results;
if (!obj) {
return cb(null,
{ bucket:
BucketInfo.fromObj(bucket).serialize(),
});
}
log.error('getObject: error getting object',
{ error: err.message });
return cb(err);
}
return cb(null, {
bucket: BucketInfo.fromObj(bucket).serialize(),
obj: JSON.stringify(obj),
});
});
return undefined;
});
}
putBucketAttributes(bucketName, bucketMD, log, cb) {