Skip to content

Commit fa9abec

Browse files
committed
Reformat with prettier
Issue: ARSN-619
1 parent 536e958 commit fa9abec

5 files changed

Lines changed: 480 additions & 397 deletions

File tree

lib/storage/metadata/bucketclient/BucketClientInterface.js

Lines changed: 105 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ const errors = require('../../../errors').default;
55

66
class BucketClientInterface {
77
constructor(params, bucketclient, logger) {
8-
assert(params.bucketdBootstrap.length > 0,
9-
'bucketd bootstrap list is empty');
8+
assert(params.bucketdBootstrap.length > 0, 'bucketd bootstrap list is empty');
109
const bootstrap = params.bucketdBootstrap;
1110
const log = params.bucketdLog;
1211
if (params.https) {
@@ -16,8 +15,7 @@ class BucketClientInterface {
1615
log,
1716
https: true,
1817
});
19-
this.client = new bucketclient.RESTClient(bootstrap, log, true,
20-
key, cert, ca);
18+
this.client = new bucketclient.RESTClient(bootstrap, log, true, key, cert, ca);
2119
} else {
2220
logger.info('bucketclient configuration', {
2321
bootstrap,
@@ -29,46 +27,47 @@ class BucketClientInterface {
2927
}
3028

3129
createBucket(bucketName, bucketMD, log, cb) {
32-
this.client.createBucket(bucketName, log.getSerializedUids(),
33-
bucketMD.serialize(), cb);
30+
this.client.createBucket(bucketName, log.getSerializedUids(), bucketMD.serialize(), cb);
3431
return null;
3532
}
3633

3734
getBucketAttributes(bucketName, log, cb) {
38-
this.client.getBucketAttributes(bucketName, log.getSerializedUids(),
39-
(err, data, raftSessionId) => {
40-
if (err) {
41-
return cb(err);
42-
}
43-
return cb(err, BucketInfo.deSerialize(data), raftSessionId);
44-
});
35+
this.client.getBucketAttributes(bucketName, log.getSerializedUids(), (err, data, raftSessionId) => {
36+
if (err) {
37+
return cb(err);
38+
}
39+
return cb(err, BucketInfo.deSerialize(data), raftSessionId);
40+
});
4541
return null;
4642
}
4743

4844
getBucketAndObject(bucketName, objName, params, log, cb) {
49-
this.client.getBucketAndObject(bucketName, objName,
50-
log.getSerializedUids(), (err, data, raftSessionId) => {
51-
if (err && (!err.is.NoSuchKey && !err.is.ObjNotFound)) {
45+
this.client.getBucketAndObject(
46+
bucketName,
47+
objName,
48+
log.getSerializedUids(),
49+
(err, data, raftSessionId) => {
50+
if (err && !err.is.NoSuchKey && !err.is.ObjNotFound) {
5251
return cb(err);
5352
}
5453
return cb(null, JSON.parse(data), raftSessionId);
55-
}, params);
54+
},
55+
params,
56+
);
5657
return null;
5758
}
5859

5960
getRaftBuckets(raftId, log, cb) {
60-
return this.client.getRaftBuckets(raftId, log.getSerializedUids(),
61-
(err, data) => {
62-
if (err) {
63-
return cb(err);
64-
}
65-
return cb(null, JSON.parse(data));
66-
});
61+
return this.client.getRaftBuckets(raftId, log.getSerializedUids(), (err, data) => {
62+
if (err) {
63+
return cb(err);
64+
}
65+
return cb(null, JSON.parse(data));
66+
});
6767
}
6868

6969
putBucketAttributes(bucketName, bucketMD, log, cb) {
70-
this.client.putBucketAttributes(bucketName, log.getSerializedUids(),
71-
bucketMD.serialize(), cb);
70+
this.client.putBucketAttributes(bucketName, log.getSerializedUids(), bucketMD.serialize(), cb);
7271
return null;
7372
}
7473

@@ -86,19 +85,23 @@ class BucketClientInterface {
8685
});
8786
return cb(errors.NotImplemented);
8887
}
89-
this.client.putObject(bucketName, objName, JSON.stringify(objVal),
90-
log.getSerializedUids(), cb, params);
88+
this.client.putObject(bucketName, objName, JSON.stringify(objVal), log.getSerializedUids(), cb, params);
9189
return null;
9290
}
9391

9492
getObject(bucketName, objName, params, log, cb) {
95-
this.client.getObject(bucketName, objName, log.getSerializedUids(),
93+
this.client.getObject(
94+
bucketName,
95+
objName,
96+
log.getSerializedUids(),
9697
(err, data) => {
9798
if (err) {
9899
return cb(err);
99100
}
100101
return cb(err, JSON.parse(data));
101-
}, params);
102+
},
103+
params,
104+
);
102105
return null;
103106
}
104107

@@ -115,41 +118,37 @@ class BucketClientInterface {
115118
params.overheadField = ['originOp'];
116119
}
117120
}
118-
this.client.deleteObject(bucketName, objName, log.getSerializedUids(),
119-
cb, params);
121+
this.client.deleteObject(bucketName, objName, log.getSerializedUids(), cb, params);
120122
return null;
121123
}
122124

123125
listObject(bucketName, params, log, cb) {
124-
this.client.listObject(bucketName, log.getSerializedUids(), params,
125-
(err, data) => {
126-
if (err) {
127-
return cb(err);
128-
}
129-
return cb(err, JSON.parse(data));
130-
});
126+
this.client.listObject(bucketName, log.getSerializedUids(), params, (err, data) => {
127+
if (err) {
128+
return cb(err);
129+
}
130+
return cb(err, JSON.parse(data));
131+
});
131132
return null;
132133
}
133134

134135
listLifecycleObject(bucketName, params, log, cb) {
135-
this.client.listObject(bucketName, log.getSerializedUids(), params,
136-
(err, data) => {
137-
if (err) {
138-
return cb(err);
139-
}
140-
return cb(null, JSON.parse(data));
141-
});
136+
this.client.listObject(bucketName, log.getSerializedUids(), params, (err, data) => {
137+
if (err) {
138+
return cb(err);
139+
}
140+
return cb(null, JSON.parse(data));
141+
});
142142
return null;
143143
}
144144

145145
listMultipartUploads(bucketName, params, log, cb) {
146-
this.client.listObject(bucketName, log.getSerializedUids(), params,
147-
(err, data) => {
148-
if (err) {
149-
return cb(err);
150-
}
151-
return cb(null, JSON.parse(data));
152-
});
146+
this.client.listObject(bucketName, log.getSerializedUids(), params, (err, data) => {
147+
if (err) {
148+
return cb(err);
149+
}
150+
return cb(null, JSON.parse(data));
151+
});
153152
return null;
154153
}
155154

@@ -162,32 +161,36 @@ class BucketClientInterface {
162161
// The healthCheck exposed by Bucketd is a light one, we need
163162
// to inspect all the RaftSession's statuses to make sense of
164163
// it:
165-
return this.client.getAllRafts(undefined, (error, payload) => {
166-
let statuses = null;
167-
try {
168-
statuses = JSON.parse(payload);
169-
} catch (e) {
170-
doFail = true;
171-
reason.msg = 'could not interpret status: invalid payload';
172-
// Can't do anything anymore if we fail here. return.
173-
return callback(doFail, reason);
174-
}
164+
return this.client.getAllRafts(
165+
undefined,
166+
(error, payload) => {
167+
let statuses = null;
168+
try {
169+
statuses = JSON.parse(payload);
170+
} catch (e) {
171+
doFail = true;
172+
reason.msg = 'could not interpret status: invalid payload';
173+
// Can't do anything anymore if we fail here. return.
174+
return callback(doFail, reason);
175+
}
175176

176-
const reducer = (acc, payload) => acc + !payload.connectedToLeader;
177-
reason.ratio = statuses.reduce(reducer, 0) / statuses.length;
178-
/* NOTE FIXME/TODO: acceptableRatio could be configured later on */
179-
reason.acceptableRatio = 0.5;
180-
/* If the RaftSession 0 (map) does not work, fail anyways */
181-
if (!doFail && !statuses[0].connectedToLeader) {
182-
doFail = true;
183-
reason.msg = 'Bucket map unavailable';
184-
}
185-
if (!doFail && reason.ratio > reason.acceptableRatio) {
186-
doFail = true;
187-
reason.msg = 'Ratio of failing Raft Sessions is too high';
188-
}
189-
return callback(doFail, reason);
190-
}, log);
177+
const reducer = (acc, payload) => acc + !payload.connectedToLeader;
178+
reason.ratio = statuses.reduce(reducer, 0) / statuses.length;
179+
/* NOTE FIXME/TODO: acceptableRatio could be configured later on */
180+
reason.acceptableRatio = 0.5;
181+
/* If the RaftSession 0 (map) does not work, fail anyways */
182+
if (!doFail && !statuses[0].connectedToLeader) {
183+
doFail = true;
184+
reason.msg = 'Bucket map unavailable';
185+
}
186+
if (!doFail && reason.ratio > reason.acceptableRatio) {
187+
doFail = true;
188+
reason.msg = 'Ratio of failing Raft Sessions is too high';
189+
}
190+
return callback(doFail, reason);
191+
},
192+
log,
193+
);
191194
}
192195

193196
/*
@@ -208,26 +211,30 @@ class BucketClientInterface {
208211
return this.client.healthcheck(log, (err, result) => {
209212
const respBody = {};
210213
if (err) {
211-
return this._analyzeHealthFailure(log, (failure, reason) => {
212-
const message = reason.msg;
213-
// Remove 'msg' from the reason payload.
214-
// eslint-disable-next-line no-param-reassign
215-
reason.msg = undefined;
216-
respBody[implName] = {
217-
code: 200,
218-
message, // Provide interpreted reason msg
219-
body: reason, // Provide analysis data
220-
};
221-
if (failure) {
222-
// Setting the `error` field is how the healthCheck
223-
// logic interprets it as an error. Don't forget it !
224-
respBody[implName].error = err;
225-
respBody[implName].code = err.code; // original error
226-
}
227-
// error returned as null so async parallel doesn't return
228-
// before all backends are checked
229-
return cb(null, respBody);
230-
}, log);
214+
return this._analyzeHealthFailure(
215+
log,
216+
(failure, reason) => {
217+
const message = reason.msg;
218+
// Remove 'msg' from the reason payload.
219+
// eslint-disable-next-line no-param-reassign
220+
reason.msg = undefined;
221+
respBody[implName] = {
222+
code: 200,
223+
message, // Provide interpreted reason msg
224+
body: reason, // Provide analysis data
225+
};
226+
if (failure) {
227+
// Setting the `error` field is how the healthCheck
228+
// logic interprets it as an error. Don't forget it !
229+
respBody[implName].error = err;
230+
respBody[implName].code = err.code; // original error
231+
}
232+
// error returned as null so async parallel doesn't return
233+
// before all backends are checked
234+
return cb(null, respBody);
235+
},
236+
log,
237+
);
231238
}
232239
const parseResult = JSON.parse(result);
233240
respBody[implName] = {

lib/storage/metadata/mongoclient/MongoClientInterface.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,8 @@ class MongoClientInterface {
11091109
}
11101110
}
11111111

1112-
return c.findOne({ _id: masterKey })
1112+
return c
1113+
.findOne({ _id: masterKey })
11131114
.then(checkObj => {
11141115
const objUpsert = !checkObj;
11151116
// initiating array of operations with version creation/update

0 commit comments

Comments
 (0)