Skip to content

Commit ce68543

Browse files
committed
fix: make openMediaHotStandby option pr subdevice, and rename from hotStandby to openMediaHotStandby
1 parent 72c765f commit ce68543

File tree

5 files changed

+44
-23
lines changed

5 files changed

+44
-23
lines changed

packages/mos-gateway/src/$schemas/devices.json

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,20 @@
6161
"ui:title": "(Optional) MOS Query Port",
6262
"ui:description": "Connect to an alternate port for 'query' port MOS messages",
6363
"default": 10542
64-
}
64+
}
6565
},
66-
"required": ["lower", "upper", "query"],
66+
"required": [
67+
"lower",
68+
"upper",
69+
"query"
70+
],
6771
"additionalProperties": false
6872
}
6973
},
70-
"required": ["id", "host"],
74+
"required": [
75+
"id",
76+
"host"
77+
],
7178
"additionalProperties": false
7279
},
7380
"secondary": {
@@ -105,10 +112,10 @@
105112
"ui:description": "How often to ping NRCS to determine connection status",
106113
"default": 30000
107114
},
108-
"hotStandby": {
115+
"openMediaHotStandby": {
109116
"type": "boolean",
110-
"ui:title": "Secondary: Hot Standby",
111-
"ui:description": "Is the secondary connection a hot standby for the primary",
117+
"ui:title": "Secondary: OpenMedia Hot Standby",
118+
"ui:description": "Is the secondary connection a OpenMedia hot standby for the primary",
112119
"default": false
113120
},
114121
"ports": {
@@ -132,16 +139,25 @@
132139
"ui:title": "(Optional) MOS Query Port",
133140
"ui:description": "Connect to an alternate port for 'query' port MOS messages",
134141
"default": 10542
135-
}
142+
}
136143
},
137-
"required": ["lower", "upper", "query"],
144+
"required": [
145+
"lower",
146+
"upper",
147+
"query"
148+
],
138149
"additionalProperties": false
139-
}
150+
}
140151
},
141-
"required": ["id", "host"],
152+
"required": [
153+
"id",
154+
"host"
155+
],
142156
"additionalProperties": false
143157
}
144158
},
145-
"required": ["primary"],
159+
"required": [
160+
"primary"
161+
],
146162
"additionalProperties": false
147-
}
163+
}

packages/mos-gateway/src/CoreMosDeviceHandler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ export class CoreMosDeviceHandler {
7575
private _pendingStoryItemChanges: Array<IStoryItemChange> = []
7676
private _pendingChangeTimeout: number = 60 * 1000
7777
private mosTypes: MosTypes
78-
private _hotStandby: boolean
78+
private _openMediaHotStandby: boolean
7979

8080
private _messageQueue: Queue
8181

82-
constructor(parent: CoreHandler, mosDevice: IMOSDevice, mosHandler: MosHandler, hotStandby: boolean) {
82+
constructor(parent: CoreHandler, mosDevice: IMOSDevice, mosHandler: MosHandler, openMediaHotStandby: boolean) {
8383
this._coreParentHandler = parent
8484
this._mosDevice = mosDevice
8585
this._mosHandler = mosHandler
86-
this._hotStandby = hotStandby
86+
this._openMediaHotStandby = openMediaHotStandby
8787

8888
this._messageQueue = new Queue()
8989

@@ -140,7 +140,7 @@ export class CoreMosDeviceHandler {
140140
let statusCode: StatusCode
141141
const messages: Array<string> = []
142142

143-
if (this._hotStandby) {
143+
if (this._openMediaHotStandby) {
144144
// OpenMedia treats secondary server as hot-standby
145145
// And thus is not considered as a warning if it's not connected
146146
if (connectionStatus.PrimaryConnected) {

packages/mos-gateway/src/coreHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ export class CoreHandler {
145145
async registerMosDevice(
146146
mosDevice: IMOSDevice,
147147
mosHandler: MosHandler,
148-
hotStandby: boolean
148+
openMediaHotStandby: boolean
149149
): Promise<CoreMosDeviceHandler> {
150150
this.logger.info('registerMosDevice -------------')
151-
const coreMos = new CoreMosDeviceHandler(this, mosDevice, mosHandler, hotStandby)
151+
const coreMos = new CoreMosDeviceHandler(this, mosDevice, mosHandler, openMediaHotStandby)
152152

153153
this._coreMosHandlers.push(coreMos)
154154
return coreMos.init().then(() => {

packages/mos-gateway/src/generated/devices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface MosDeviceConfig {
2424
dontUseQueryPort?: boolean
2525
timeout?: number
2626
heartbeatInterval?: number
27-
hotStandby?: boolean
27+
openMediaHotStandby?: boolean
2828
ports?: {
2929
lower: number
3030
upper: number

packages/mos-gateway/src/mosHandler.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ export class MosHandler {
5959
private _logger: Winston.Logger
6060
private _disposed = false
6161
private _settings?: MosGatewayConfig
62-
private _hotStandby: boolean
62+
private _openMediaHotStandby: Record<string, boolean>
6363
private _coreHandler: CoreHandler | undefined
6464
private _observers: Array<Observer<any>> = []
6565
private _triggerupdateDevicesTimeout: any = null
6666
private mosTypes: MosTypes
6767

6868
constructor(logger: Winston.Logger) {
6969
this._logger = logger
70-
this._hotStandby = false
70+
this._openMediaHotStandby = {}
7171
this.mosTypes = getMosTypes(this.strict) // temporary, another will be set upon init()
7272
}
7373
async init(config: MosConfig, coreHandler: CoreHandler): Promise<void> {
@@ -243,7 +243,11 @@ export class MosHandler {
243243

244244
if (!this._coreHandler) throw Error('_coreHandler is undefined!')
245245

246-
const coreMosHandler = await this._coreHandler.registerMosDevice(mosDevice, this, this._hotStandby)
246+
const coreMosHandler = await this._coreHandler.registerMosDevice(
247+
mosDevice,
248+
this,
249+
mosDevice.idSecondary ? this._openMediaHotStandby[mosDevice.idSecondary] : false
250+
)
247251
// this._logger.info('mosDevice registered -------------')
248252
// Setup message flow between the devices:
249253

@@ -420,7 +424,8 @@ export class MosHandler {
420424
for (const [deviceId, device] of Object.entries<{ options: MosDeviceConfig }>(devices)) {
421425
if (device) {
422426
if (device.options.secondary) {
423-
this._hotStandby = device.options.secondary?.hotStandby || false
427+
this._openMediaHotStandby[device.options.secondary.id] =
428+
device.options.secondary?.openMediaHotStandby || false
424429
// If the host isn't set, don't use secondary:
425430
if (!device.options.secondary.host || !device.options.secondary.id)
426431
delete device.options.secondary

0 commit comments

Comments
 (0)