Observer embryo, Maestro done
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { AccesRights } from '../accesRights.js'
|
||||
|
||||
export class observerServer {
|
||||
|
||||
constructor(configHelper, allRediscnx, debug) {
|
||||
this.configHelper = configHelper
|
||||
this.observerConfig = configHelper.config
|
||||
this.allRediscnx = allRediscnx
|
||||
this.debug = debug
|
||||
this.accessRights = new AccesRights(this.observerConfig, debug)
|
||||
this.arenaCnx = null
|
||||
this.arenaCnxs = []
|
||||
this.systemCnx = null
|
||||
}
|
||||
|
||||
getObserverSettings() {
|
||||
const observer = this.observerConfig.observer ?? {}
|
||||
return({
|
||||
senderId: observer.senderId ?? 'observer',
|
||||
lifecycle: {
|
||||
arenaChannel: observer.lifecycle?.arenaChannel ?? 'arena:lifecycle',
|
||||
godsReadyChannel: observer.lifecycle?.godsReadyChannel ?? 'arena:gods:ready',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
wireSystemConnexion(cnx) {
|
||||
cnx.observerSrv = this
|
||||
cnx.accessRights = this.accessRights
|
||||
cnx.reloadAccessRights = () => this.reloadAccessRights()
|
||||
cnx.getAccessRights = () => this.getAccessRights()
|
||||
if(!this.systemCnx || cnx.redisConfig.role === 'primary') {
|
||||
this.systemCnx = cnx
|
||||
}
|
||||
}
|
||||
|
||||
wireArenaConnexion(cnx) {
|
||||
cnx.observerSrv = this
|
||||
this.arenaCnxs.push(cnx)
|
||||
if(!this.arenaCnx || cnx.redisConfig.role === 'primary') {
|
||||
this.arenaCnx = cnx
|
||||
}
|
||||
}
|
||||
|
||||
async reloadAccessRights() {
|
||||
await this.configHelper.refreshAccessRights()
|
||||
this.observerConfig.accessRights = this.configHelper.config.accessRights
|
||||
this.accessRights.refreshAccessRights(this.observerConfig)
|
||||
}
|
||||
|
||||
getAccessRights() {
|
||||
return(this.observerConfig.accessRights)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user