Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow InfluxService to be registered without 'initial ping' #1468

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading