-
Notifications
You must be signed in to change notification settings - Fork 38
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
feat(MOS): support OpenMedia's hot standby #1169
base: release51
Are you sure you want to change the base?
Changes from all commits
e7f59e2
cef3236
484b0d7
e49715e
72c765f
ce68543
e2fe446
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -142,9 +142,13 @@ export class CoreHandler { | |||||
|
||||||
return options | ||||||
} | ||||||
async registerMosDevice(mosDevice: IMOSDevice, mosHandler: MosHandler): Promise<CoreMosDeviceHandler> { | ||||||
async registerMosDevice( | ||||||
mosDevice: IMOSDevice, | ||||||
mosHandler: MosHandler, | ||||||
openMediaHotStandby: boolean | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above - I understand that these additional options are necessary to pass around, but maybe we could group these flags into some sort of an options object where their meaning will be available, and not as just boolean arguments into functions?
Suggested change
|
||||||
): Promise<CoreMosDeviceHandler> { | ||||||
this.logger.info('registerMosDevice -------------') | ||||||
const coreMos = new CoreMosDeviceHandler(this, mosDevice, mosHandler) | ||||||
const coreMos = new CoreMosDeviceHandler(this, mosDevice, mosHandler, openMediaHotStandby) | ||||||
|
||||||
this._coreMosHandlers.push(coreMos) | ||||||
return coreMos.init().then(() => { | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,13 +59,15 @@ export class MosHandler { | |
private _logger: Winston.Logger | ||
private _disposed = false | ||
private _settings?: MosGatewayConfig | ||
private _openMediaHotStandby: Record<string, boolean> | ||
private _coreHandler: CoreHandler | undefined | ||
private _observers: Array<Observer<any>> = [] | ||
private _triggerupdateDevicesTimeout: any = null | ||
private mosTypes: MosTypes | ||
|
||
constructor(logger: Winston.Logger) { | ||
this._logger = logger | ||
this._openMediaHotStandby = {} | ||
this.mosTypes = getMosTypes(this.strict) // temporary, another will be set upon init() | ||
} | ||
async init(config: MosConfig, coreHandler: CoreHandler): Promise<void> { | ||
|
@@ -101,7 +103,7 @@ export class MosHandler { | |
|
||
this.mosTypes = getMosTypes(this.strict) | ||
|
||
await this._initMosConnection() | ||
await this._updateDevices() | ||
|
||
if (!this._coreHandler) throw Error('_coreHandler is undefined!') | ||
this._coreHandler.onConnected(() => { | ||
|
@@ -110,8 +112,6 @@ export class MosHandler { | |
this.sendStatusOfAllMosDevices() | ||
}) | ||
this.setupObservers() | ||
|
||
return this._updateDevices() | ||
} | ||
async dispose(): Promise<void> { | ||
this._disposed = true | ||
|
@@ -243,7 +243,11 @@ export class MosHandler { | |
|
||
if (!this._coreHandler) throw Error('_coreHandler is undefined!') | ||
|
||
const coreMosHandler = await this._coreHandler.registerMosDevice(mosDevice, this) | ||
const coreMosHandler = await this._coreHandler.registerMosDevice( | ||
mosDevice, | ||
this, | ||
mosDevice.idSecondary ? this._openMediaHotStandby[mosDevice.idSecondary] : false | ||
) | ||
// this._logger.info('mosDevice registered -------------') | ||
// Setup message flow between the devices: | ||
|
||
|
@@ -420,6 +424,8 @@ export class MosHandler { | |
for (const [deviceId, device] of Object.entries<{ options: MosDeviceConfig }>(devices)) { | ||
if (device) { | ||
if (device.options.secondary) { | ||
this._openMediaHotStandby[device.options.secondary.id] = | ||
device.options.secondary?.openMediaHotStandby || false | ||
// If the host isn't set, don't use secondary: | ||
if (!device.options.secondary.host || !device.options.secondary.id) | ||
delete device.options.secondary | ||
|
@@ -482,6 +488,11 @@ export class MosHandler { | |
deviceOptions.primary.heartbeatInterval = | ||
deviceOptions.primary.heartbeatInterval || DEFAULT_MOS_HEARTBEAT_INTERVAL | ||
|
||
if (deviceOptions.secondary?.id && this._openMediaHotStandby[deviceOptions.secondary.id]) { | ||
//@ts-expect-error this is not yet added to the official mos-connection | ||
deviceOptions.secondary.openMediaHotStandby = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean that this PR is not mergable yet? Because there needs to be an update to mos-connection before? |
||
} | ||
|
||
const mosDevice: MosDevice = await this.mos.connect(deviceOptions) | ||
this._ownMosDevices[deviceId] = mosDevice | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this should be put into an options object? Carrying these opaque flags enabling out-of-spec behavior seems like something that will get problematic very quickly. What about?