mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-23 23:42:29 +00:00
Throttle state report patches to once per 10 seconds
Change-type: patch Closes: #1158 Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
231284e06b
commit
4b0f431f9b
@ -13,6 +13,7 @@ import Database from './db';
|
||||
import { EventTracker } from './event-tracker';
|
||||
import { loadBackupFromMigration } from './lib/migration';
|
||||
|
||||
import constants = require('./lib/constants');
|
||||
import {
|
||||
ContractValidationError,
|
||||
ContractViolationError,
|
||||
@ -485,7 +486,7 @@ export class APIBinder {
|
||||
};
|
||||
}
|
||||
|
||||
private async report() {
|
||||
private report = _.throttle(async () => {
|
||||
const conf = await this.config.getMany([
|
||||
'deviceId',
|
||||
'apiTimeout',
|
||||
@ -531,7 +532,7 @@ export class APIBinder {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, constants.maxReportFrequency);
|
||||
|
||||
private reportCurrentState(): null {
|
||||
(async () => {
|
||||
@ -600,7 +601,6 @@ export class APIBinder {
|
||||
}
|
||||
|
||||
private async pollTargetState(isInitialCall: boolean = false): Promise<void> {
|
||||
// TODO: Remove the checkInt here with the config changes
|
||||
const {
|
||||
appUpdatePollInterval,
|
||||
instantUpdates,
|
||||
|
@ -56,6 +56,8 @@ const constants = {
|
||||
backoffIncrement: 500,
|
||||
supervisorNetworkSubnet: '10.114.104.0/25',
|
||||
supervisorNetworkGateway: '10.114.104.1',
|
||||
// How often can we report our state to the server in ms
|
||||
maxReportFrequency: 10 * 1000,
|
||||
};
|
||||
|
||||
if (process.env.DOCKER_HOST == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user