Skip to content

Commit

Permalink
Merge pull request #9 from LOKE/feature/update_prettier
Browse files Browse the repository at this point in the history
Update prettier
  • Loading branch information
midhilkari authored Jun 1, 2021
2 parents 10b4f24 + ad1558b commit be0cebc
Show file tree
Hide file tree
Showing 8 changed files with 760 additions and 514 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
node_js:
- '6'
- lts/*
- "10"
- lts/*
deploy:
provider: npm
email: [email protected]
Expand Down
36 changes: 18 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ const IPC_MANIFESTS_FOLDER = "ipc_manifests";
const requestDuration = new Histogram({
name: "http_rpc_client_request_duration_seconds",
help: "Duration of rpc requests from the client",
labelNames: ["service", "method"]
labelNames: ["service", "method"],
});
const requestCount = new Counter({
name: "http_rpc_client_requests_total",
help: "The total number of rpc requests from the client",
labelNames: ["service", "method"]
labelNames: ["service", "method"],
});
const failureCount = new Counter({
name: "http_rpc_client_failures_total",
help: "The total number of rpc failures from the client",
labelNames: ["service", "method", "type", "status_code"]
labelNames: ["service", "method", "type", "status_code"],
});

class RpcResponseError {
Expand All @@ -31,7 +31,7 @@ class RpcResponseError {
configurable: true,
enumerable: false,
value: this.constructor.name,
writable: true
writable: true,
});

Object.assign(this, responseBody);
Expand All @@ -46,9 +46,9 @@ class RpcResponseError {
"\n" +
[...this.source]
.reverse()
.map(s => " via " + s)
.map((s) => " via " + s)
.join("\n"),
writable: true
writable: true,
});
}

Expand All @@ -61,7 +61,7 @@ class RpcResponseError {
}
}

exports.load = function(host, serviceName, options) {
exports.load = function (host, serviceName, options) {
const metaPath = getMetaPath(serviceName);
const client = new Client(host, options);

Expand Down Expand Up @@ -100,7 +100,7 @@ class Client {
Object.assign(
this,
{
path: "/rpc"
path: "/rpc",
},
options
);
Expand Down Expand Up @@ -128,21 +128,21 @@ class Client {
.post(requestUrl, {
body: JSON.stringify(params),
headers: {
"Content-Type": "application/json"
"Content-Type": "application/json",
},
json: true,
retries: 0,
timeout
timeout,
})
.then(res => res.body)
.catch(err => {
.then((res) => res.body)
.catch((err) => {
failureCount.inc(
Object.assign(
{
type:
(err.response && err.response.body && err.response.body.type) ||
undefined,
status_code: err.statusCode
status_code: err.statusCode,
},
requestMeta
)
Expand All @@ -160,16 +160,16 @@ class Client {
protocol: this.protocol,
host: this.host,
port: this.port,
pathname: pathname
pathname: pathname,
});
}

getMeta() {
const requestUrl = this.formatUrl();

return got(requestUrl, { json: true })
.then(res => res.body)
.catch(err => mapError(this.serviceName, "getMeta", err));
.then((res) => res.body)
.catch((err) => mapError(this.serviceName, "getMeta", err));
}

createInterface(meta) {
Expand All @@ -179,8 +179,8 @@ class Client {
const multiArg = meta.multiArg || false;
const self = this;

meta.interfaces.forEach(iface => {
rpcInterface[iface.methodName] = function() {
meta.interfaces.forEach((iface) => {
rpcInterface[iface.methodName] = function () {
const args = Array.prototype.slice.call(arguments);
const params = multiArg ? args : args[0];
if (!multiArg && params && typeof params !== "object")
Expand Down
Loading

0 comments on commit be0cebc

Please sign in to comment.