tons of cursor-shit cleaning, finished implementing cnxId in observer
This commit is contained in:
+18
-38
@@ -10,10 +10,12 @@ export class maestroServer {
|
||||
|
||||
constructor(configHelper, allRediscnx, debug) {
|
||||
this.configHelper = configHelper
|
||||
this.maestroConfig = configHelper.config
|
||||
this.rootConfig = configHelper.config
|
||||
this.maestroConfig = configHelper.config.maestro ?? {}
|
||||
this.gpsConfig = configHelper.config.gps ?? {}
|
||||
this.allRediscnx = allRediscnx
|
||||
this.debug = debug
|
||||
this.accessRights = new AccesRights(this.maestroConfig, debug)
|
||||
this.accessRights = new AccesRights(this.rootConfig, debug)
|
||||
this.arenaCnx = null
|
||||
this.arenaCnxs = []
|
||||
this.systemCnx = null
|
||||
@@ -31,26 +33,6 @@ export class maestroServer {
|
||||
this.pausedAt = null
|
||||
}
|
||||
|
||||
getMaestroSettings() {
|
||||
const maestro = this.maestroConfig.maestro ?? {}
|
||||
return({
|
||||
senderId: maestro.senderId ?? 'maestro',
|
||||
lifecycle: {
|
||||
arenaChannel: maestro.lifecycle?.arenaChannel ?? 'arena:lifecycle',
|
||||
prepareAckChannel: maestro.lifecycle?.godsReadyChannel ?? 'arena:gods:ready',
|
||||
},
|
||||
readyTimeoutMs: maestro.readyTimeoutMs ?? 30000,
|
||||
})
|
||||
}
|
||||
|
||||
getArenaStorageSettings() {
|
||||
const gps = this.maestroConfig.gps ?? {}
|
||||
return({
|
||||
agentHashKey: gps.arenaStorage?.agentHashKey ?? 'arena:agents:[UID]',
|
||||
agentsIndexKey: gps.arenaStorage?.agentsIndexKey ?? 'arena:agents',
|
||||
})
|
||||
}
|
||||
|
||||
isIdle() {
|
||||
return(this.orchestrationState === MaestroState.IDLE)
|
||||
}
|
||||
@@ -72,7 +54,7 @@ export class maestroServer {
|
||||
}
|
||||
|
||||
async init() {
|
||||
const mysqlCfg = this.maestroConfig.mysql
|
||||
const mysqlCfg = this.rootConfig.mysql
|
||||
if(!mysqlCfg) {
|
||||
console.error('[Maestro] Missing mysql config')
|
||||
return(false)
|
||||
@@ -84,10 +66,11 @@ export class maestroServer {
|
||||
}
|
||||
|
||||
refreshArenaGroom() {
|
||||
if(this.arenaCnx) {
|
||||
const arenaStorage = this.gpsConfig.arenaStorage
|
||||
if(this.arenaCnx && arenaStorage) {
|
||||
this.arenaGroom = new ArenaGroom(
|
||||
this.arenaCnx,
|
||||
this.getArenaStorageSettings(),
|
||||
arenaStorage,
|
||||
this.debug
|
||||
)
|
||||
}
|
||||
@@ -95,10 +78,9 @@ export class maestroServer {
|
||||
|
||||
refreshPrepareQuorum() {
|
||||
if(!this.arenaCnx) return
|
||||
const { lifecycle, readyTimeoutMs } = this.getMaestroSettings()
|
||||
this.prepareQuorum = new PrepareQuorum({
|
||||
ackChannel: lifecycle.prepareAckChannel,
|
||||
timeoutMs: readyTimeoutMs,
|
||||
ackChannel: this.maestroConfig.lifecycle.godsReadyChannel,
|
||||
timeoutMs: this.maestroConfig.readyTimeoutMs,
|
||||
matchesChan: this.arenaCnx.matchesChan.bind(this.arenaCnx),
|
||||
debug: this.debug,
|
||||
})
|
||||
@@ -144,11 +126,10 @@ export class maestroServer {
|
||||
|
||||
async publishLifecycle(eventType, payload, state = null) {
|
||||
if(!this.arenaCnx) throw(new Error('No arena Redis connection'))
|
||||
const { arenaChannel, senderId } = this.getMaestroSettings().lifecycle
|
||||
const resolvedState = state ?? this.orchestrationStateFor(payload?.simulationId ?? this.simulationId)
|
||||
await this.arenaCnx.redisPublish(arenaChannel, {
|
||||
await this.arenaCnx.redisPublish(this.maestroConfig.lifecycle.arenaChannel, {
|
||||
eventType,
|
||||
sender: senderId,
|
||||
sender: this.maestroConfig.senderId,
|
||||
payload,
|
||||
})
|
||||
await this.publishSystemLifecycle(eventType, payload, resolvedState)
|
||||
@@ -164,9 +145,8 @@ export class maestroServer {
|
||||
const ownersResult = await this.simRepo.listSimulationOwnerUuids(simulationId)
|
||||
if(!ownersResult.ok || !ownersResult.ownerUuids.length) return
|
||||
|
||||
const maestro = this.maestroConfig.maestro ?? {}
|
||||
const channelTemplate = maestro.systemLifecycleChannel ?? 'system:maestro:lifecycle:[UID]'
|
||||
const senderId = maestro.senderId ?? 'maestro'
|
||||
const channelTemplate = this.maestroConfig.systemLifecycleChannel
|
||||
const senderId = this.maestroConfig.senderId
|
||||
const msg = {
|
||||
eventType,
|
||||
sender: senderId,
|
||||
@@ -219,7 +199,7 @@ export class maestroServer {
|
||||
infraId,
|
||||
}
|
||||
|
||||
const expectedParticipants = buildPrepareQuorum(this.agentIds, this.maestroConfig)
|
||||
const expectedParticipants = buildPrepareQuorum(this.agentIds, this.rootConfig)
|
||||
const readyWait = this.prepareQuorum.begin(expectedParticipants, this.simulationId)
|
||||
|
||||
await this.publishLifecycle('onYourMarks', lifecyclePayload)
|
||||
@@ -410,12 +390,12 @@ export class maestroServer {
|
||||
|
||||
async reloadAccessRights() {
|
||||
await this.configHelper.refreshAccessRights()
|
||||
this.maestroConfig.accessRights = this.configHelper.config.accessRights
|
||||
this.accessRights.refreshAccessRights(this.maestroConfig)
|
||||
this.rootConfig.accessRights = this.configHelper.config.accessRights
|
||||
this.accessRights.refreshAccessRights(this.rootConfig)
|
||||
}
|
||||
|
||||
getAccessRights() {
|
||||
return(this.maestroConfig.accessRights)
|
||||
return(this.rootConfig.accessRights)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user