Skip to content

Commit

Permalink
Fixup post review
Browse files Browse the repository at this point in the history
  • Loading branch information
benzekrimaha committed Oct 21, 2024
1 parent 715e940 commit d55e172
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 21 deletions.
6 changes: 3 additions & 3 deletions lib/hdcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class HDProxydClient {
._failover(method, stream, size, key, counter, log, callback, params);
}
receivedResponse = true;
log.debug('request received response');
log.end('request received response');
return callback(err, ret);
}, args, payload);
}
Expand All @@ -198,7 +198,7 @@ class HDProxydClient {
* creation and its sending.
*/
_handleRequest(method, stream, size, key, log, callback, params, payload) {
//tslint:disable-next-line:no-any
// tslint:disable-next-line:no-any
const headers = (params.headers ? params.headers : {});
const req = this._createRequestHeader(method, headers, key, params, log);
const host = this.getCurrentBootstrap();
Expand Down Expand Up @@ -374,7 +374,7 @@ class HDProxydClient {
hostname: currentBootstrap[0],
port: currentBootstrap[1],
method: 'GET',
path: '/metrics', // XXX
path: '/metrics',
headers: {
'X-Scal-Request-Uids': logger.getSerializedUids(),
},
Expand Down
7 changes: 1 addition & 6 deletions lib/shuffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ function nextBytes(numBytes) {
return randomBytes(numBytes);
}
catch (ex) {
if (ex instanceof Error) {
throw new Error(`Insufficient entropy: ${ex.message}`);
}
else {
throw new Error('Insufficient entropy: Unknown error');
}
throw new Error(`Insufficient entropy: ${ex instanceof Error ? ex.message : "Unknown error"}`);
}
}
/*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "tsc --strict ",
"coverage": "nyc --check-coverage --exclude 'tests/*' --lines=90 --reporter=text --reporter=html --reporter=lcov npm test tests/",
"jsdoc": "jsdoc src/ tests/ -d docs/jsdoc",
"lint": "eslint $(git ls-files '*.ts')",
"lint": "eslint $(git ls-files '*.ts' '*.js')",
"test": "mocha --require ts-node/register --use_strict --check-leaks --recursive tests/**/*.ts",
"get-version": "echo $npm_package_version"
},
Expand Down
10 changes: 4 additions & 6 deletions src/hdcontroller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
'use strict';

import * as assert from 'assert';
import * as async from 'async';
Expand Down Expand Up @@ -186,9 +186,7 @@ export class HDProxydClient {
reqHeaders['X-Scal-Request-Uids'] = reqUids;
reqHeaders['X-Scal-Trace-Ids'] = reqUids;
if (params && params.range) {

reqHeaders.Range = `bytes=${params.range[0]}-${params.range[1]}`;

}
let realPath: string;
if (key === '/job/delete') {
Expand Down Expand Up @@ -237,7 +235,7 @@ export class HDProxydClient {
callback, params);
}
receivedResponse = true;
log.debug('request received response');
log.end('request received response');
return callback(err, ret);
}, args, payload);
}
Expand All @@ -250,7 +248,7 @@ export class HDProxydClient {
size: number, key: string, log: werelogs.RequestLogger,
callback: HDProxydCallback, params: Params,
payload: object | undefined): void {
//tslint:disable-next-line:no-any
// tslint:disable-next-line:no-any
const headers = ( params.headers ? params.headers : {}) as { 'content-length'?: number; [key: string]: any };
const req = this._createRequestHeader(method, headers, key, params,
log);
Expand Down Expand Up @@ -430,7 +428,7 @@ export class HDProxydClient {
hostname: currentBootstrap[0],
port: currentBootstrap[1],
method: 'GET',
path: '/metrics', // XXX
path: '/metrics',
headers: {
'X-Scal-Request-Uids': logger.getSerializedUids(),
},
Expand Down
6 changes: 1 addition & 5 deletions src/shuffle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ function nextBytes(numBytes: number): Buffer {
try {
return randomBytes(numBytes);
} catch (ex) {
if (ex instanceof Error) {
throw new Error(`Insufficient entropy: ${ex.message}`);
} else {
throw new Error('Insufficient entropy: Unknown error');
}
throw new Error(`Insufficient entropy: ${ex instanceof Error ? ex.message : "Unknown error"}`);
}
}

Expand Down

0 comments on commit d55e172

Please sign in to comment.