Add debug prints, fix POST request

This commit is contained in:
Mononaut 2023-08-05 19:17:20 +09:00
parent 2095f90262
commit e512feef74
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E

View File

@ -105,6 +105,8 @@ class FailoverRouter {
this.sortHosts();
logger.debug(`Tomahawk ranking: ${this.hosts.map(host => '\navg latency ' + Math.round(host.latency).toString().padStart(5, ' ') + ' | reachable? ' + !(host.unreachable || false).toString().padStart(5, ' ') + ' | in sync? ' + !(host.outOfSync || false).toString().padStart(5, ' ') + ` | ${host.host}`).join('')}`);
// switch if the current host is out of sync or significantly slower than the next best alternative
if (this.activeHost.outOfSync || this.activeHost.unreachable || (!this.activeHost.preferred && this.activeHost.latency > (this.hosts[0].latency * 2) + 50)) {
if (this.activeHost.unreachable) {
@ -196,7 +198,7 @@ class FailoverRouter {
}
public async $post<T>(path, data: any, responseType = 'json'): Promise<T> {
return this.$query<T>('post', path, null, responseType);
return this.$query<T>('post', path, data, responseType);
}
}