-
Notifications
You must be signed in to change notification settings - Fork 0
Node.ts
Baterka edited this page Jan 8, 2020
·
7 revisions
Node instance definition.
Variables:
- id:
NodeId
- rightNode:
NodeReference
- leader:
boolean
- watchingLeader:
boolean
- slaveNodes:
NodeReference[]
- electionParticipant:
boolean
- circleHealthy:
boolean
- timeStamp:
number
; - Log:
Logger
- httpServer:
Http.Server | undefined
- expressApp:
Express.Application | undefined
- wsServer:
WebSocket.Server | undefined
- sharedVariable:
any
- signedIn:
boolean
- nextDisconnectIsNotFail:
boolean
- leaderId:
NodeId | undefined
Methods:
- constructor(
rightNodeId: NodeId, nodeId: NodeId = new NodeId('127.0.0.1', 3000), isLeader: boolean = false
) -
static
sendMessage(node: NodeReference, msg: Message
) -
public
getId():string
-
public
toString():string
-
private
startServer():void
-
private
setExpressRoutes(app: Express.Application
):void
-
private
async propagateVariable(variable: any, failOnFirst: boolean = false
):Promise<boolean>
-
private
onConnection(socket: WebSocket, req: Http.IncomingMessage
):void
-
private
onMessageServer(socket: WebSocket, rawMsg: string
):void
-
private
setHealthCorrupted():void
-
private
incrementTimestamp():void
-
private
forwardMessage(msg: Message
):void
-
private
connectToSlaves(slaves: { ipAddress: string, port: number } []
):void
-
private
async initHealthCheck():Promise<void>
-
private
async initLeaderElection():Promise<void>
-
private
sendHealthCheck():void
-
private
connectToNode(node: NodeReference, reconnect: boolean = false
):void
-
private
reportNodeFailure():void
-
private
onMessageClient(socket: WebSocket, rawMsg: string
):void