mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-19 11:16:34 +00:00
Workaround a circular dependency
Change-type: patch
This commit is contained in:
parent
d402bebee1
commit
a59af6abe8
@ -44,7 +44,6 @@ export interface APIBinderConstructOpts {
|
||||
config: Config;
|
||||
// FIXME: Remove this
|
||||
db: Database;
|
||||
deviceState: DeviceState;
|
||||
eventTracker: EventTracker;
|
||||
logger: Logger;
|
||||
}
|
||||
@ -94,20 +93,18 @@ export class APIBinder {
|
||||
private targetStateFetchErrors = 0;
|
||||
private readyForUpdates = false;
|
||||
|
||||
public constructor({
|
||||
config,
|
||||
deviceState,
|
||||
eventTracker,
|
||||
logger,
|
||||
}: APIBinderConstructOpts) {
|
||||
public constructor({ config, eventTracker, logger }: APIBinderConstructOpts) {
|
||||
this.config = config;
|
||||
this.deviceState = deviceState;
|
||||
this.eventTracker = eventTracker;
|
||||
this.logger = logger;
|
||||
|
||||
this.router = this.createAPIBinderRouter(this);
|
||||
}
|
||||
|
||||
public setDeviceState(deviceState: DeviceState) {
|
||||
this.deviceState = deviceState;
|
||||
}
|
||||
|
||||
public async healthcheck() {
|
||||
const {
|
||||
appUpdatePollInterval,
|
||||
|
@ -43,7 +43,6 @@ export class Supervisor {
|
||||
this.apiBinder = new APIBinder({
|
||||
config: this.config,
|
||||
db: this.db,
|
||||
deviceState: this.deviceState,
|
||||
eventTracker: this.eventTracker,
|
||||
logger: this.logger,
|
||||
});
|
||||
@ -54,6 +53,8 @@ export class Supervisor {
|
||||
logger: this.logger,
|
||||
apiBinder: this.apiBinder,
|
||||
});
|
||||
// workaround the circular dependency
|
||||
this.apiBinder.setDeviceState(this.deviceState);
|
||||
|
||||
// FIXME: rearchitect proxyvisor to avoid this circular dependency
|
||||
// by storing current state and having the APIBinder query and report it / provision devices
|
||||
|
@ -34,7 +34,6 @@ const initModels = async (obj: Dictionary<any>, filename: string) => {
|
||||
config: obj.config,
|
||||
logger: obj.logger,
|
||||
eventTracker: obj.eventTracker,
|
||||
deviceState: obj.deviceState,
|
||||
});
|
||||
|
||||
obj.deviceState = new DeviceState({
|
||||
@ -44,6 +43,9 @@ const initModels = async (obj: Dictionary<any>, filename: string) => {
|
||||
logger: obj.logger,
|
||||
apiBinder: obj.apiBinder,
|
||||
});
|
||||
|
||||
obj.apiBinder.setDeviceState(obj.deviceState);
|
||||
|
||||
await obj.db.init();
|
||||
await obj.config.init();
|
||||
await obj.apiBinder.initClient(); // Initializes the clients but doesn't trigger provisioning
|
||||
|
Loading…
Reference in New Issue
Block a user