Skip to content

Commit

Permalink
fix: Allow InfluxService to be registered without 'initial ping' (#1468)
Browse files Browse the repository at this point in the history
* fix: Allow InfluxService to be registered without 'initial ping' dependency (if it's configured we assume it works and register)

* chore: bump version to v3.3.10-rc.2

---------

Co-authored-by: Begoña Álvarez de la Cruz <[email protected]>
  • Loading branch information
msarcev and begonaalvarezd authored May 8, 2024
1 parent 172d196 commit 0289727
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 29 deletions.
4 changes: 2 additions & 2 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "explorer-api",
"description": "API for Tangle Explorer",
"version": "3.3.10-rc.1",
"version": "3.3.10-rc.2",
"author": "Martyn Janes <[email protected]>",
"repository": {
"type": "git",
Expand Down
28 changes: 6 additions & 22 deletions api/src/services/stardust/influx/influxDbClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { INanoDate, InfluxDB, IPingStats, IResults, toNanoDate } from "influx";
import { INanoDate, InfluxDB, IResults, toNanoDate } from "influx";
import moment from "moment";
import cron from "node-cron";
import {
Expand Down Expand Up @@ -134,7 +134,7 @@ export abstract class InfluxDbClient {

/**
* Build a new client instance asynchronously.
* @returns Boolean representing that the client ping succeeded.
* @returns Boolean representing that the client was initialised.
*/
public async buildClient(): Promise<boolean> {
const protocol = this._network.analyticsInfluxDbProtocol || "https";
Expand All @@ -157,27 +157,11 @@ export abstract class InfluxDbClient {

const influxDbClient = new InfluxDB({ protocol, port, host, database, username, password, options });

return influxDbClient
.ping(1500)
.then((pingResults: IPingStats[]) => {
if (pingResults.length > 0) {
const anyHostIsOnline = pingResults.some((ping) => ping.online);
this._client = influxDbClient;
this.setupDataCollection();
logger.info(`[InfluxDb] Client started for "${network}"...`);

if (anyHostIsOnline) {
logger.info(`[InfluxDb] Client started for "${network}"...`);
this._client = influxDbClient;
this.setupDataCollection();
}

return anyHostIsOnline;
}

return false;
})
.catch((e) => {
logger.verbose(`[InfluxDb] Ping failed for "${network}". ${e}`);
return false;
});
return true;
}

logger.warn(`[InfluxDb] Configuration not found for "${network}".`);
Expand Down
4 changes: 2 additions & 2 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "explorer-client",
"description": "Tangle Explorer UI",
"version": "3.3.10-rc.1",
"version": "3.3.10-rc.2",
"author": "Martyn Janes <[email protected]>",
"type": "module",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "explorer",
"description": "Tangle Explorer",
"version": "3.3.10-rc.1",
"version": "3.3.10-rc.2",
"scripts": {
"setup:client": "cd client && npm install && npm run postinstall",
"setup:api": "cd api && npm install && npm run build-compile && npm run build-config",
Expand Down

0 comments on commit 0289727

Please sign in to comment.