@nsshunt/stsappframework 3.1.214 → 3.1.216
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonTypes.js.map +1 -1
- package/dist/index.js +1 -7
- package/dist/index.js.map +1 -1
- package/dist/serverprocessbase.js +2 -2
- package/dist/serverprocessbase.js.map +1 -1
- package/dist/stscontrollerbase.js.map +1 -1
- package/dist/{server.js → stsexpressserver.js} +1 -1
- package/dist/stsexpressserver.js.map +1 -0
- package/dist/stslatencycontroller.js.map +1 -1
- package/dist/stslatencyroute.js.map +1 -1
- package/dist/stsrouterbase.js.map +1 -1
- package/dist/vitesttesting/appSingleWSS.js +2 -1
- package/dist/vitesttesting/appSingleWSS.js.map +1 -1
- package/dist/workerprocessbase.js.map +1 -1
- package/package.json +5 -6
- package/src/commonTypes.ts +2 -0
- package/src/index.ts +1 -7
- package/src/serverprocessbase.ts +1 -1
- package/src/{socketIoServerHelper.ts → socketIoServerHelper.ts_bak} +1 -2
- package/src/stscontrollerbase.ts +1 -2
- package/src/{server.ts → stsexpressserver.ts} +1 -2
- package/src/stslatencycontroller.ts +1 -2
- package/src/stslatencyroute.ts +1 -2
- package/src/stsrouterbase.ts +1 -2
- package/src/vitesttesting/appSingleWSS.ts +2 -1
- package/src/workerprocessbase.ts +1 -2
- package/types/commonTypes.d.ts +0 -15
- package/types/commonTypes.d.ts.map +1 -1
- package/types/index.d.ts +0 -7
- package/types/index.d.ts.map +1 -1
- package/types/serverprocessbase.d.ts +1 -1
- package/types/serverprocessbase.d.ts.map +1 -1
- package/types/stscontrollerbase.d.ts.map +1 -1
- package/types/{server.d.ts → stsexpressserver.d.ts} +1 -1
- package/types/stsexpressserver.d.ts.map +1 -0
- package/types/stslatencycontroller.d.ts.map +1 -1
- package/types/stslatencyroute.d.ts.map +1 -1
- package/types/stsrouterbase.d.ts.map +1 -1
- package/types/vitesttesting/appSingleWSS.d.ts.map +1 -1
- package/types/workerprocessbase.d.ts.map +1 -1
- package/dist/authDefs.js +0 -33
- package/dist/authDefs.js.map +0 -1
- package/dist/gRPC/ststest/protos/auth_sample.js +0 -3
- package/dist/gRPC/ststest/protos/auth_sample.js.map +0 -1
- package/dist/gRPC/ststest/protos/echo.js +0 -3
- package/dist/gRPC/ststest/protos/echo.js.map +0 -1
- package/dist/gRPC/ststest/protos/grpc/examples/echo/Echo.js +0 -4
- package/dist/gRPC/ststest/protos/grpc/examples/echo/Echo.js.map +0 -1
- package/dist/gRPC/ststest/protos/grpc/examples/echo/EchoRequest.js +0 -4
- package/dist/gRPC/ststest/protos/grpc/examples/echo/EchoRequest.js.map +0 -1
- package/dist/gRPC/ststest/protos/grpc/examples/echo/EchoResponse.js +0 -4
- package/dist/gRPC/ststest/protos/grpc/examples/echo/EchoResponse.js.map +0 -1
- package/dist/gRPC/ststest/protos/grpc/testing/Request.js +0 -4
- package/dist/gRPC/ststest/protos/grpc/testing/Request.js.map +0 -1
- package/dist/gRPC/ststest/protos/grpc/testing/Response.js +0 -4
- package/dist/gRPC/ststest/protos/grpc/testing/Response.js.map +0 -1
- package/dist/gRPC/ststest/protos/grpc/testing/TestService.js +0 -4
- package/dist/gRPC/ststest/protos/grpc/testing/TestService.js.map +0 -1
- package/dist/gRPC/ststest/protos/hellostreamingworld/HelloReply.js +0 -4
- package/dist/gRPC/ststest/protos/hellostreamingworld/HelloReply.js.map +0 -1
- package/dist/gRPC/ststest/protos/hellostreamingworld/HelloRequest.js +0 -4
- package/dist/gRPC/ststest/protos/hellostreamingworld/HelloRequest.js.map +0 -1
- package/dist/gRPC/ststest/protos/hellostreamingworld/MultiGreeter.js +0 -4
- package/dist/gRPC/ststest/protos/hellostreamingworld/MultiGreeter.js.map +0 -1
- package/dist/gRPC/ststest/protos/hellostreamingworld.js +0 -3
- package/dist/gRPC/ststest/protos/hellostreamingworld.js.map +0 -1
- package/dist/gRPC/ststest/protos/helloworld/Greeter.js +0 -4
- package/dist/gRPC/ststest/protos/helloworld/Greeter.js.map +0 -1
- package/dist/gRPC/ststest/protos/helloworld/HelloReply.js +0 -4
- package/dist/gRPC/ststest/protos/helloworld/HelloReply.js.map +0 -1
- package/dist/gRPC/ststest/protos/helloworld/HelloRequest.js +0 -4
- package/dist/gRPC/ststest/protos/helloworld/HelloRequest.js.map +0 -1
- package/dist/gRPC/ststest/protos/helloworld.js +0 -3
- package/dist/gRPC/ststest/protos/helloworld.js.map +0 -1
- package/dist/gRPC/ststest/protos/keyvaluestore/KeyValueStore.js +0 -4
- package/dist/gRPC/ststest/protos/keyvaluestore/KeyValueStore.js.map +0 -1
- package/dist/gRPC/ststest/protos/keyvaluestore/Request.js +0 -4
- package/dist/gRPC/ststest/protos/keyvaluestore/Request.js.map +0 -1
- package/dist/gRPC/ststest/protos/keyvaluestore/Response.js +0 -4
- package/dist/gRPC/ststest/protos/keyvaluestore/Response.js.map +0 -1
- package/dist/gRPC/ststest/protos/keyvaluestore.js +0 -3
- package/dist/gRPC/ststest/protos/keyvaluestore.js.map +0 -1
- package/dist/gRPC/ststest/protos/route_guide.js +0 -3
- package/dist/gRPC/ststest/protos/route_guide.js.map +0 -1
- package/dist/gRPC/ststest/protos/routeguide/Feature.js +0 -4
- package/dist/gRPC/ststest/protos/routeguide/Feature.js.map +0 -1
- package/dist/gRPC/ststest/protos/routeguide/Point.js +0 -4
- package/dist/gRPC/ststest/protos/routeguide/Point.js.map +0 -1
- package/dist/gRPC/ststest/protos/routeguide/Rectangle.js +0 -4
- package/dist/gRPC/ststest/protos/routeguide/Rectangle.js.map +0 -1
- package/dist/gRPC/ststest/protos/routeguide/RouteGuide.js +0 -4
- package/dist/gRPC/ststest/protos/routeguide/RouteGuide.js.map +0 -1
- package/dist/gRPC/ststest/protos/routeguide/RouteNote.js +0 -4
- package/dist/gRPC/ststest/protos/routeguide/RouteNote.js.map +0 -1
- package/dist/gRPC/ststest/protos/routeguide/RouteSummary.js +0 -4
- package/dist/gRPC/ststest/protos/routeguide/RouteSummary.js.map +0 -1
- package/dist/gRPC/ststest/src/commonTypes.js +0 -3
- package/dist/gRPC/ststest/src/commonTypes.js.map +0 -1
- package/dist/gRPC/ststest/src/greeter_client.js +0 -67
- package/dist/gRPC/ststest/src/greeter_client.js.map +0 -1
- package/dist/gRPC/ststest/src/greeter_server.js +0 -78
- package/dist/gRPC/ststest/src/greeter_server.js.map +0 -1
- package/dist/gRPC/ststest/src/route_guide_client.js +0 -258
- package/dist/gRPC/ststest/src/route_guide_client.js.map +0 -1
- package/dist/gRPC/ststest/src/route_guide_server.js +0 -237
- package/dist/gRPC/ststest/src/route_guide_server.js.map +0 -1
- package/dist/gRPC/ststest/src/route_guide_server2.js +0 -205
- package/dist/gRPC/ststest/src/route_guide_server2.js.map +0 -1
- package/dist/influxdb/influxDBManager.js +0 -304
- package/dist/influxdb/influxDBManager.js.map +0 -1
- package/dist/influxdb/influxDBManagerAgent.js +0 -14
- package/dist/influxdb/influxDBManagerAgent.js.map +0 -1
- package/dist/influxdb/influxDBManagerBase.js +0 -100
- package/dist/influxdb/influxDBManagerBase.js.map +0 -1
- package/dist/influxdb/influxDBManagerLambda.js +0 -17
- package/dist/influxdb/influxDBManagerLambda.js.map +0 -1
- package/dist/influxdb/influxDBManagerService.js +0 -14
- package/dist/influxdb/influxDBManagerService.js.map +0 -1
- package/dist/publishInstrumentsWebWorker.js +0 -159
- package/dist/publishInstrumentsWebWorker.js.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/socketIoServerHelper.js +0 -125
- package/dist/socketIoServerHelper.js.map +0 -1
- package/dist/tcpclient/app.js +0 -23
- package/dist/tcpclient/app.js.map +0 -1
- package/dist/tcpclient/app2.js +0 -57
- package/dist/tcpclient/app2.js.map +0 -1
- package/dist/tcpserver/app.js +0 -16
- package/dist/tcpserver/app.js.map +0 -1
- package/dist/tcpserver/appConfig.js +0 -83
- package/dist/tcpserver/appConfig.js.map +0 -1
- package/dist/tcpserver/appmaster.js +0 -446
- package/dist/tcpserver/appmaster.js.map +0 -1
- package/dist/testertesting/app.js +0 -284
- package/dist/testertesting/app.js.map +0 -1
- package/dist/testertesting/commonTypes.js +0 -47
- package/dist/testertesting/commonTypes.js.map +0 -1
- package/dist/testertesting/telemetryProcessor.js +0 -111
- package/dist/testertesting/telemetryProcessor.js.map +0 -1
- package/dist/testertesting/testCase01.js +0 -169
- package/dist/testertesting/testCase01.js.map +0 -1
- package/dist/testertesting/workerInstance.js +0 -263
- package/dist/testertesting/workerInstance.js.map +0 -1
- package/dist/testertesting/workerManager.js +0 -450
- package/dist/testertesting/workerManager.js.map +0 -1
- package/dist/testertesting/workerWorkerTestRunner01.js +0 -35
- package/dist/testertesting/workerWorkerTestRunner01.js.map +0 -1
- package/dist/testing/app.js +0 -18
- package/dist/testing/app.js.map +0 -1
- package/dist/testing/appConfig.js +0 -93
- package/dist/testing/appConfig.js.map +0 -1
- package/dist/testing/appTinyEmitter.js +0 -37
- package/dist/testing/appTinyEmitter.js.map +0 -1
- package/dist/testing/appWorkerWSS.js +0 -151
- package/dist/testing/appWorkerWSS.js.map +0 -1
- package/dist/testing/appredistest.js +0 -239
- package/dist/testing/appredistest.js.map +0 -1
- package/dist/testing/appsolo.js +0 -67
- package/dist/testing/appsolo.js.map +0 -1
- package/dist/testing/promiseTesting.js +0 -77
- package/dist/testing/promiseTesting.js.map +0 -1
- package/dist/testing/server.js +0 -15
- package/dist/testing/server.js.map +0 -1
- package/dist/testing/wsevents.js +0 -3
- package/dist/testing/wsevents.js.map +0 -1
- package/dist/webworkertesting/app.js +0 -44
- package/dist/webworkertesting/app.js.map +0 -1
- package/dist/webworkertesting/worker.js +0 -21
- package/dist/webworkertesting/worker.js.map +0 -1
- package/src/authDefs.ts +0 -37
- package/src/gRPC/ststest/protos/BUILD +0 -82
- package/src/gRPC/ststest/protos/README.md +0 -8
- package/src/gRPC/ststest/protos/auth_sample.proto +0 -42
- package/src/gRPC/ststest/protos/auth_sample.ts +0 -20
- package/src/gRPC/ststest/protos/echo.proto +0 -45
- package/src/gRPC/ststest/protos/echo.ts +0 -22
- package/src/gRPC/ststest/protos/grpc/examples/echo/Echo.ts +0 -55
- package/src/gRPC/ststest/protos/grpc/examples/echo/EchoRequest.ts +0 -10
- package/src/gRPC/ststest/protos/grpc/examples/echo/EchoResponse.ts +0 -10
- package/src/gRPC/ststest/protos/grpc/testing/Request.ts +0 -12
- package/src/gRPC/ststest/protos/grpc/testing/Response.ts +0 -12
- package/src/gRPC/ststest/protos/grpc/testing/TestService.ts +0 -27
- package/src/gRPC/ststest/protos/hellostreamingworld/HelloReply.ts +0 -10
- package/src/gRPC/ststest/protos/hellostreamingworld/HelloRequest.ts +0 -12
- package/src/gRPC/ststest/protos/hellostreamingworld/MultiGreeter.ts +0 -23
- package/src/gRPC/ststest/protos/hellostreamingworld.proto +0 -39
- package/src/gRPC/ststest/protos/hellostreamingworld.ts +0 -18
- package/src/gRPC/ststest/protos/helloworld/Greeter.ts +0 -35
- package/src/gRPC/ststest/protos/helloworld/HelloReply.ts +0 -10
- package/src/gRPC/ststest/protos/helloworld/HelloRequest.ts +0 -10
- package/src/gRPC/ststest/protos/helloworld.proto +0 -40
- package/src/gRPC/ststest/protos/helloworld.ts +0 -18
- package/src/gRPC/ststest/protos/keyvaluestore/KeyValueStore.ts +0 -23
- package/src/gRPC/ststest/protos/keyvaluestore/Request.ts +0 -10
- package/src/gRPC/ststest/protos/keyvaluestore/Response.ts +0 -10
- package/src/gRPC/ststest/protos/keyvaluestore.proto +0 -33
- package/src/gRPC/ststest/protos/keyvaluestore.ts +0 -18
- package/src/gRPC/ststest/protos/route_guide.proto +0 -111
- package/src/gRPC/ststest/protos/route_guide.ts +0 -21
- package/src/gRPC/ststest/protos/routeguide/Feature.ts +0 -13
- package/src/gRPC/ststest/protos/routeguide/Point.ts +0 -12
- package/src/gRPC/ststest/protos/routeguide/Rectangle.ts +0 -13
- package/src/gRPC/ststest/protos/routeguide/RouteGuide.ts +0 -58
- package/src/gRPC/ststest/protos/routeguide/RouteNote.ts +0 -13
- package/src/gRPC/ststest/protos/routeguide/RouteSummary.ts +0 -16
- package/src/gRPC/ststest/src/commonTypes.ts +0 -27
- package/src/gRPC/ststest/src/greeter_client.ts +0 -52
- package/src/gRPC/ststest/src/greeter_server.ts +0 -62
- package/src/gRPC/ststest/src/route_guide_client.ts +0 -266
- package/src/gRPC/ststest/src/route_guide_server.ts +0 -234
- package/src/gRPC/ststest/src/route_guide_server2.ts +0 -211
- package/src/influxdb/influxDBManager.ts +0 -334
- package/src/influxdb/influxDBManagerAgent.ts +0 -14
- package/src/influxdb/influxDBManagerBase.ts +0 -108
- package/src/influxdb/influxDBManagerLambda.ts +0 -17
- package/src/influxdb/influxDBManagerService.ts +0 -14
- package/src/publishInstrumentsWebWorker.ts +0 -157
- package/src/tcpclient/app.ts +0 -21
- package/src/tcpclient/app2.ts +0 -58
- package/src/tcpserver/app.ts +0 -11
- package/src/tcpserver/appConfig.ts +0 -99
- package/src/tcpserver/appmaster.ts +0 -503
- package/src/testertesting/app.ts +0 -349
- package/src/testertesting/commonTypes.ts +0 -236
- package/src/testertesting/telemetryProcessor.ts +0 -125
- package/src/testertesting/testCase01.ts +0 -207
- package/src/testertesting/workerInstance.ts +0 -297
- package/src/testertesting/workerManager.ts +0 -511
- package/src/testertesting/workerWorkerTestRunner01.ts +0 -34
- package/src/testing/app.ts +0 -14
- package/src/testing/appConfig.ts +0 -110
- package/src/testing/appTinyEmitter.ts +0 -57
- package/src/testing/appWorkerWSS.ts +0 -174
- package/src/testing/appredistest.ts +0 -304
- package/src/testing/appsolo.ts +0 -96
- package/src/testing/docker-compose.yml +0 -20
- package/src/testing/promiseTesting.ts +0 -86
- package/src/testing/server.ts +0 -17
- package/src/testing/wsevents.ts +0 -33
- package/src/webworkertesting/app.ts +0 -56
- package/src/webworkertesting/worker.ts +0 -24
- package/types/authDefs.d.ts +0 -29
- package/types/authDefs.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/auth_sample.d.ts +0 -19
- package/types/gRPC/ststest/protos/auth_sample.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/echo.d.ts +0 -21
- package/types/gRPC/ststest/protos/echo.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/grpc/examples/echo/Echo.d.ts +0 -43
- package/types/gRPC/ststest/protos/grpc/examples/echo/Echo.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/grpc/examples/echo/EchoRequest.d.ts +0 -7
- package/types/gRPC/ststest/protos/grpc/examples/echo/EchoRequest.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/grpc/examples/echo/EchoResponse.d.ts +0 -7
- package/types/gRPC/ststest/protos/grpc/examples/echo/EchoResponse.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/grpc/testing/Request.d.ts +0 -9
- package/types/gRPC/ststest/protos/grpc/testing/Request.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/grpc/testing/Response.d.ts +0 -9
- package/types/gRPC/ststest/protos/grpc/testing/Response.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/grpc/testing/TestService.d.ts +0 -21
- package/types/gRPC/ststest/protos/grpc/testing/TestService.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/hellostreamingworld/HelloReply.d.ts +0 -7
- package/types/gRPC/ststest/protos/hellostreamingworld/HelloReply.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/hellostreamingworld/HelloRequest.d.ts +0 -9
- package/types/gRPC/ststest/protos/hellostreamingworld/HelloRequest.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/hellostreamingworld/MultiGreeter.d.ts +0 -17
- package/types/gRPC/ststest/protos/hellostreamingworld/MultiGreeter.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/hellostreamingworld.d.ts +0 -17
- package/types/gRPC/ststest/protos/hellostreamingworld.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/helloworld/Greeter.d.ts +0 -27
- package/types/gRPC/ststest/protos/helloworld/Greeter.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/helloworld/HelloReply.d.ts +0 -7
- package/types/gRPC/ststest/protos/helloworld/HelloReply.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/helloworld/HelloRequest.d.ts +0 -7
- package/types/gRPC/ststest/protos/helloworld/HelloRequest.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/helloworld.d.ts +0 -17
- package/types/gRPC/ststest/protos/helloworld.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/keyvaluestore/KeyValueStore.d.ts +0 -17
- package/types/gRPC/ststest/protos/keyvaluestore/KeyValueStore.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/keyvaluestore/Request.d.ts +0 -7
- package/types/gRPC/ststest/protos/keyvaluestore/Request.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/keyvaluestore/Response.d.ts +0 -7
- package/types/gRPC/ststest/protos/keyvaluestore/Response.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/keyvaluestore.d.ts +0 -17
- package/types/gRPC/ststest/protos/keyvaluestore.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/route_guide.d.ts +0 -20
- package/types/gRPC/ststest/protos/route_guide.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/routeguide/Feature.d.ts +0 -10
- package/types/gRPC/ststest/protos/routeguide/Feature.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/routeguide/Point.d.ts +0 -9
- package/types/gRPC/ststest/protos/routeguide/Point.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/routeguide/Rectangle.d.ts +0 -10
- package/types/gRPC/ststest/protos/routeguide/Rectangle.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/routeguide/RouteGuide.d.ts +0 -46
- package/types/gRPC/ststest/protos/routeguide/RouteGuide.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/routeguide/RouteNote.d.ts +0 -10
- package/types/gRPC/ststest/protos/routeguide/RouteNote.d.ts.map +0 -1
- package/types/gRPC/ststest/protos/routeguide/RouteSummary.d.ts +0 -13
- package/types/gRPC/ststest/protos/routeguide/RouteSummary.d.ts.map +0 -1
- package/types/gRPC/ststest/src/commonTypes.d.ts +0 -23
- package/types/gRPC/ststest/src/commonTypes.d.ts.map +0 -1
- package/types/gRPC/ststest/src/greeter_client.d.ts +0 -3
- package/types/gRPC/ststest/src/greeter_client.d.ts.map +0 -1
- package/types/gRPC/ststest/src/greeter_server.d.ts +0 -3
- package/types/gRPC/ststest/src/greeter_server.d.ts.map +0 -1
- package/types/gRPC/ststest/src/route_guide_client.d.ts +0 -3
- package/types/gRPC/ststest/src/route_guide_client.d.ts.map +0 -1
- package/types/gRPC/ststest/src/route_guide_server.d.ts +0 -3
- package/types/gRPC/ststest/src/route_guide_server.d.ts.map +0 -1
- package/types/gRPC/ststest/src/route_guide_server2.d.ts +0 -3
- package/types/gRPC/ststest/src/route_guide_server2.d.ts.map +0 -1
- package/types/influxdb/influxDBManager.d.ts +0 -21
- package/types/influxdb/influxDBManager.d.ts.map +0 -1
- package/types/influxdb/influxDBManagerAgent.d.ts +0 -8
- package/types/influxdb/influxDBManagerAgent.d.ts.map +0 -1
- package/types/influxdb/influxDBManagerBase.d.ts +0 -14
- package/types/influxdb/influxDBManagerBase.d.ts.map +0 -1
- package/types/influxdb/influxDBManagerLambda.d.ts +0 -11
- package/types/influxdb/influxDBManagerLambda.d.ts.map +0 -1
- package/types/influxdb/influxDBManagerService.d.ts +0 -8
- package/types/influxdb/influxDBManagerService.d.ts.map +0 -1
- package/types/publishInstrumentsWebWorker.d.ts +0 -1
- package/types/publishInstrumentsWebWorker.d.ts.map +0 -1
- package/types/server.d.ts.map +0 -1
- package/types/socketIoServerHelper.d.ts +0 -20
- package/types/socketIoServerHelper.d.ts.map +0 -1
- package/types/tcpclient/app.d.ts +0 -2
- package/types/tcpclient/app.d.ts.map +0 -1
- package/types/tcpclient/app2.d.ts +0 -2
- package/types/tcpclient/app2.d.ts.map +0 -1
- package/types/tcpserver/app.d.ts +0 -2
- package/types/tcpserver/app.d.ts.map +0 -1
- package/types/tcpserver/appConfig.d.ts +0 -3
- package/types/tcpserver/appConfig.d.ts.map +0 -1
- package/types/tcpserver/appmaster.d.ts +0 -24
- package/types/tcpserver/appmaster.d.ts.map +0 -1
- package/types/testertesting/app.d.ts +0 -2
- package/types/testertesting/app.d.ts.map +0 -1
- package/types/testertesting/commonTypes.d.ts +0 -215
- package/types/testertesting/commonTypes.d.ts.map +0 -1
- package/types/testertesting/telemetryProcessor.d.ts +0 -6
- package/types/testertesting/telemetryProcessor.d.ts.map +0 -1
- package/types/testertesting/testCase01.d.ts +0 -20
- package/types/testertesting/testCase01.d.ts.map +0 -1
- package/types/testertesting/workerInstance.d.ts +0 -23
- package/types/testertesting/workerInstance.d.ts.map +0 -1
- package/types/testertesting/workerManager.d.ts +0 -16
- package/types/testertesting/workerManager.d.ts.map +0 -1
- package/types/testertesting/workerWorkerTestRunner01.d.ts +0 -7
- package/types/testertesting/workerWorkerTestRunner01.d.ts.map +0 -1
- package/types/testing/app.d.ts +0 -2
- package/types/testing/app.d.ts.map +0 -1
- package/types/testing/appConfig.d.ts +0 -3
- package/types/testing/appConfig.d.ts.map +0 -1
- package/types/testing/appTinyEmitter.d.ts +0 -2
- package/types/testing/appTinyEmitter.d.ts.map +0 -1
- package/types/testing/appWorkerWSS.d.ts +0 -26
- package/types/testing/appWorkerWSS.d.ts.map +0 -1
- package/types/testing/appredistest.d.ts +0 -4
- package/types/testing/appredistest.d.ts.map +0 -1
- package/types/testing/appsolo.d.ts +0 -3
- package/types/testing/appsolo.d.ts.map +0 -1
- package/types/testing/promiseTesting.d.ts +0 -4
- package/types/testing/promiseTesting.d.ts.map +0 -1
- package/types/testing/server.d.ts +0 -6
- package/types/testing/server.d.ts.map +0 -1
- package/types/testing/wsevents.d.ts +0 -18
- package/types/testing/wsevents.d.ts.map +0 -1
- package/types/webworkertesting/app.d.ts +0 -2
- package/types/webworkertesting/app.d.ts.map +0 -1
- package/types/webworkertesting/worker.d.ts +0 -2
- package/types/webworkertesting/worker.d.ts.map +0 -1
|
@@ -1,503 +0,0 @@
|
|
|
1
|
-
/* eslint @typescript-eslint/no-explicit-any: 0, @typescript-eslint/no-unused-vars: 0 */ // --> OFF
|
|
2
|
-
import fs from "fs"
|
|
3
|
-
import crypto from 'crypto';
|
|
4
|
-
import jayson from 'jayson'
|
|
5
|
-
import net from 'node:net'
|
|
6
|
-
import tls from 'node:tls'
|
|
7
|
-
|
|
8
|
-
import { JSONObject } from '@nsshunt/stsutils';
|
|
9
|
-
import { MasterProcessBase } from './../masterprocessbase'
|
|
10
|
-
import { ProcessOptions } from './../commonTypes'
|
|
11
|
-
|
|
12
|
-
import chalk from 'chalk';
|
|
13
|
-
|
|
14
|
-
// Colour codes
|
|
15
|
-
// ---------------------------------
|
|
16
|
-
// Red - Error
|
|
17
|
-
// Green - Vote YES
|
|
18
|
-
// Yellow - Vote No
|
|
19
|
-
// White - standard logging message
|
|
20
|
-
// Magenta - node state change
|
|
21
|
-
// Cyan - node term change
|
|
22
|
-
|
|
23
|
-
export enum AppMasterRAFTState {
|
|
24
|
-
IDLE = "IDLE",
|
|
25
|
-
FOLLOWER = "FOLLOWER",
|
|
26
|
-
CANDIDATE = "CANDIDATE",
|
|
27
|
-
LEADER = "LEADER"
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface IServiceDetail {
|
|
31
|
-
host: string
|
|
32
|
-
port: number
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface ILogItem {
|
|
36
|
-
term: number
|
|
37
|
-
index: number
|
|
38
|
-
data: JSONObject | null
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export class AppMaster extends MasterProcessBase
|
|
42
|
-
{
|
|
43
|
-
#lastRequiredVotes = -1; // used for logging only
|
|
44
|
-
#lastVotes = -1; // used for logging only
|
|
45
|
-
#RAFTState: AppMasterRAFTState;
|
|
46
|
-
#minElectionTimeout: number;
|
|
47
|
-
#maxElectionTimeout: number;
|
|
48
|
-
#electionTimeout: number;
|
|
49
|
-
#heartBeatTimeout: number;
|
|
50
|
-
#startRAFTProtocolTimeout: number;
|
|
51
|
-
#votes: JSONObject; // keyed by service key (host:port)
|
|
52
|
-
#services: IServiceDetail[];
|
|
53
|
-
#thisService: IServiceDetail;
|
|
54
|
-
#canidateTimeout: NodeJS.Timeout | null = null;
|
|
55
|
-
#serverPort: number;
|
|
56
|
-
#votedLog: JSONObject = { }; // keyed by term number
|
|
57
|
-
#appendedEntries: JSONObject = { };
|
|
58
|
-
#leaderNode: IServiceDetail | null = null;
|
|
59
|
-
|
|
60
|
-
#currentTerm: number;
|
|
61
|
-
#log: ILogItem[];
|
|
62
|
-
#currentIndex = 0;
|
|
63
|
-
|
|
64
|
-
constructor(serviceConfig: ProcessOptions)
|
|
65
|
-
{
|
|
66
|
-
super(serviceConfig);
|
|
67
|
-
this.#RAFTState = AppMasterRAFTState.IDLE;
|
|
68
|
-
this.#currentTerm = 0;
|
|
69
|
-
this.#votes = { };
|
|
70
|
-
this.#services = [{
|
|
71
|
-
host: "stscore.stsmda.org",
|
|
72
|
-
port: 3006
|
|
73
|
-
}, {
|
|
74
|
-
host: "stscore.stsmda.org",
|
|
75
|
-
port: 3007
|
|
76
|
-
}, {
|
|
77
|
-
host: "stscore.stsmda.org",
|
|
78
|
-
port: 3008
|
|
79
|
-
}]
|
|
80
|
-
|
|
81
|
-
this.#thisService = this.#services[parseInt(process.env.SERVICE_INDEX as string)]; // set self service
|
|
82
|
-
this.#serverPort = this.#thisService.port;
|
|
83
|
-
|
|
84
|
-
//this.#thisService = this.#services[0]; // set self service
|
|
85
|
-
this.#log = [ ]; // Need to get from storage - volume, redis, etc.
|
|
86
|
-
|
|
87
|
-
// Set default config items
|
|
88
|
-
this.#minElectionTimeout = 1000; //@@ config
|
|
89
|
-
this.#maxElectionTimeout = 1200; //@@ config
|
|
90
|
-
this.#startRAFTProtocolTimeout = 2000; //@@ config
|
|
91
|
-
this.#electionTimeout = crypto.randomInt(this.#minElectionTimeout, this.#maxElectionTimeout);
|
|
92
|
-
this.#heartBeatTimeout = 750; //@@ config - also must be smaller than electionTimeout
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
#LogInfoMessage(message: any) {
|
|
96
|
-
this.options.logger.error(message);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
#GetTLSOptions = (): JSONObject => {
|
|
100
|
-
return {
|
|
101
|
-
key: fs.readFileSync(this.options.httpsServerKeyPath),
|
|
102
|
-
cert: fs.readFileSync(this.options.httpsServerCertificatePath)
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
#GetLogPrefix = () => {
|
|
107
|
-
return `${this.#thisService.host}:${this.#thisService.port}: currentTerm: [${this.#currentTerm}] index: [${this.#currentIndex}]: `;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
#VoteYes = (callback: any, term: number, message: string) => {
|
|
111
|
-
// Log the fact that I have now voted for this currentTerm
|
|
112
|
-
this.#votedLog[term] = true;
|
|
113
|
-
// Update my currentTerm
|
|
114
|
-
this.#currentTerm = term;
|
|
115
|
-
// Return my yes vote
|
|
116
|
-
this.#LogInfoMessage(chalk.green(`${message} - Vote Yes`));
|
|
117
|
-
callback(null, true); // YES vote
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
#VoteNo = (callback: any, term: number, message: string) => {
|
|
121
|
-
// Log the fact that I have now voted for this currentTerm
|
|
122
|
-
this.#votedLog[term] = true;
|
|
123
|
-
// Return my yes vote
|
|
124
|
-
this.#LogInfoMessage(chalk.yellow(`${message} - Vote No`));
|
|
125
|
-
callback(null, false); // NO vote
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
#FindService = (host: string, port: number): IServiceDetail | null => {
|
|
129
|
-
let retService = null;
|
|
130
|
-
this.#services.forEach((service, index) => {
|
|
131
|
-
if (service.host.localeCompare(host) === 0 && service.port === port) {
|
|
132
|
-
retService = service;
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
return retService;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
#CheckMoreRecentTerm = (term: number, lastLogItemTerm: number, lastLogItemIndex: number) => {
|
|
140
|
-
// Check if the request to vote is newer than my current term
|
|
141
|
-
let msg = '';
|
|
142
|
-
let retVal: boolean;
|
|
143
|
-
if (term > this.#currentTerm) {
|
|
144
|
-
|
|
145
|
-
msg = `${this.#GetLogPrefix()}: canidate term: [${term}] greater than my currentTerm: [${this.#currentTerm}]`;
|
|
146
|
-
retVal = true;
|
|
147
|
-
} else {
|
|
148
|
-
// Check if the request to vote is older than my current term
|
|
149
|
-
if (term === this.#currentTerm) {
|
|
150
|
-
if (lastLogItemIndex > this.#currentIndex) {
|
|
151
|
-
msg = `${this.#GetLogPrefix()}: canidate term: [${term}] the same as my currentTerm: [${this.#currentTerm}]. Canidate index: [${lastLogItemIndex}] greater than my index: [${this.#currentIndex}]`;
|
|
152
|
-
retVal = true;
|
|
153
|
-
} else if (lastLogItemIndex === this.#currentIndex) {
|
|
154
|
-
msg = `${this.#GetLogPrefix()}: canidate term: [${term}] the same as my currentTerm: [${this.#currentTerm}]. Canidate index: [${lastLogItemIndex}] the same as my index: [${this.#currentIndex}]`;
|
|
155
|
-
retVal = true;
|
|
156
|
-
} else {
|
|
157
|
-
msg = `${this.#GetLogPrefix()}: canidate term: [${term}] the same as my currentTerm: [${this.#currentTerm}]. Canidate index: [${lastLogItemIndex}] NOT greater than my index: [${this.#currentIndex}]`;
|
|
158
|
-
retVal = false;
|
|
159
|
-
}
|
|
160
|
-
} else {
|
|
161
|
-
msg = `${this.#GetLogPrefix()}: canidate term: [${term}] less than my currentTerm: [${this.#currentTerm}]`;
|
|
162
|
-
retVal = false;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return {
|
|
166
|
-
msg,
|
|
167
|
-
retVal
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
#SetupJSONRPCServer = async (): Promise<jayson.TlsServer> => {
|
|
172
|
-
const jaysonServer = new jayson.server();
|
|
173
|
-
|
|
174
|
-
jaysonServer.method("appendEntries", async (args: any, callback: any) => {
|
|
175
|
-
// Just received a message - reset my electionTimeout
|
|
176
|
-
this.#ResetElectionTimeout();
|
|
177
|
-
|
|
178
|
-
// Do something with this new log entry
|
|
179
|
-
|
|
180
|
-
// Needs to check if current, otherwise get old entries and duplicate
|
|
181
|
-
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
jaysonServer.method("vote", async (args: any, callback: any) => {
|
|
185
|
-
// Just received a message - reset my electionTimeout
|
|
186
|
-
this.#ResetElectionTimeout();
|
|
187
|
-
|
|
188
|
-
const term = args[0];
|
|
189
|
-
const lastLogItemTerm = args[1];
|
|
190
|
-
const lastLogItemIndex = args[2];
|
|
191
|
-
|
|
192
|
-
// Now determine whether this requestror gets my vote
|
|
193
|
-
|
|
194
|
-
// Check already voted
|
|
195
|
-
if (this.#votedLog[term]) {
|
|
196
|
-
this.#VoteNo(callback, term, `${this.#GetLogPrefix()}: Already voted - vote NO`)
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Check if the request to vote is newer than my current term
|
|
201
|
-
const retVal = this.#CheckMoreRecentTerm(term, lastLogItemTerm, lastLogItemIndex);
|
|
202
|
-
if (retVal.retVal === true) {
|
|
203
|
-
this.#VoteYes(callback, term, retVal.msg);
|
|
204
|
-
} else {
|
|
205
|
-
this.#VoteNo(callback, term, retVal.msg);
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
jaysonServer.method("appendEntry", async (args: any, callback: any) => {
|
|
210
|
-
// Just received a message - reset my electionTimeout
|
|
211
|
-
this.#ResetElectionTimeout();
|
|
212
|
-
|
|
213
|
-
const host = args[0];
|
|
214
|
-
const port = args[1];
|
|
215
|
-
const term = args[2];
|
|
216
|
-
const lastLogItemTerm = args[3];
|
|
217
|
-
const lastLogItemIndex = args[4];
|
|
218
|
-
|
|
219
|
-
if (this.#RAFTState.localeCompare(AppMasterRAFTState.CANDIDATE) === 0) {
|
|
220
|
-
const retVal = this.#CheckMoreRecentTerm(term, lastLogItemTerm, lastLogItemIndex);
|
|
221
|
-
if (retVal.retVal === true) {
|
|
222
|
-
this.#LogInfoMessage(`${retVal.msg}`);
|
|
223
|
-
this.#LogInfoMessage(chalk.magenta(`${this.#GetLogPrefix()}: New leader detected, Host: [${host}], Port: [${port}], while in CANDIDATE mode, reverting to FOLLOWER.`));
|
|
224
|
-
// This sending node is the leader so revert to follower
|
|
225
|
-
this.#currentTerm = term;
|
|
226
|
-
this.#ChangeState(AppMasterRAFTState.FOLLOWER);
|
|
227
|
-
} else {
|
|
228
|
-
this.#LogInfoMessage(`${retVal.msg}`);
|
|
229
|
-
this.#LogInfoMessage(chalk.magenta(`${this.#GetLogPrefix()}: appendEntry called but log is older than my current state, Host: [${host}], Port: [${port}].`));
|
|
230
|
-
// Reject this RPC and continue in the CANDIDATE state
|
|
231
|
-
callback(null, false);
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
} else if (this.#RAFTState.localeCompare(AppMasterRAFTState.LEADER) === 0) {
|
|
235
|
-
this.#LogInfoMessage(chalk.red(`${this.#GetLogPrefix()}: appendEntry called while I am the current leader, rejecting RPC call.`));
|
|
236
|
-
// Reject this RPC and continue in the LEADER state
|
|
237
|
-
callback(null, false);
|
|
238
|
-
return;
|
|
239
|
-
} else {
|
|
240
|
-
// FOLLOWER or IDLE
|
|
241
|
-
if (this.#RAFTState.localeCompare(AppMasterRAFTState.IDLE) === 0) {
|
|
242
|
-
this.#ChangeState(AppMasterRAFTState.FOLLOWER);
|
|
243
|
-
}
|
|
244
|
-
const retVal = this.#CheckMoreRecentTerm(term, lastLogItemTerm, lastLogItemIndex);
|
|
245
|
-
if (retVal.retVal === true) {
|
|
246
|
-
if (term > this.#currentTerm) {
|
|
247
|
-
this.#LogInfoMessage(chalk.cyan(`${retVal.msg}`));
|
|
248
|
-
this.#currentTerm = term;
|
|
249
|
-
}
|
|
250
|
-
} else {
|
|
251
|
-
this.#LogInfoMessage(`${retVal.msg}`);
|
|
252
|
-
this.#LogInfoMessage(chalk.magenta(`${this.#GetLogPrefix()}: appendEntry called but log is older than my current state, Host: [${host}], Port: [${port}].`));
|
|
253
|
-
// Reject this RPC and continue in the CANDIDATE state
|
|
254
|
-
callback(null, false);
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (this.#leaderNode) {
|
|
260
|
-
const sentLeaderService = this.#FindService(host, port);
|
|
261
|
-
if (sentLeaderService) {
|
|
262
|
-
if (sentLeaderService.host.localeCompare(this.#leaderNode.host) !== 0 || sentLeaderService.port !== this.#leaderNode.port) {
|
|
263
|
-
this.#leaderNode = sentLeaderService;
|
|
264
|
-
this.#LogInfoMessage(chalk.white(`${this.#GetLogPrefix()}: Leader Service: Host:[${this.#leaderNode.host}] Port: [${this.#leaderNode.port}]`));
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
} else {
|
|
268
|
-
this.#leaderNode = this.#FindService(host, port);
|
|
269
|
-
if (this.#leaderNode) {
|
|
270
|
-
this.#LogInfoMessage(chalk.white(`${this.#GetLogPrefix()}: Leader Service: Host:[${this.#leaderNode.host}] Port: [${this.#leaderNode.port}]`));
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// Now update the log if only more recent
|
|
275
|
-
callback(null, true);
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
jaysonServer.method("ping", async (args: any, callback: any) => {
|
|
279
|
-
// do something, do nothing
|
|
280
|
-
this.#LogInfoMessage('server got ping');
|
|
281
|
-
callback();
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
const server = jaysonServer.tls(this.#GetTLSOptions());
|
|
285
|
-
//(server as tls.Server).on('secureConnection', this.#SetupRPCServer);
|
|
286
|
-
//server.listen(this.options.listenPort, () => { // 'stscore.stsmda.org'
|
|
287
|
-
server.listen(this.#serverPort, () => { // 'stscore.stsmda.org'
|
|
288
|
-
this.#LogInfoMessage('JSON RPC 2.0 Server is running on port ' + this.options.listenPort + '.');
|
|
289
|
-
}).on('listening', () =>
|
|
290
|
-
{
|
|
291
|
-
this.LogInfoMessage(`JSON RPC 2.0 live on ${this.options.endpoint}:${this.options.listenPort}${this.options.apiRoot}`);
|
|
292
|
-
});
|
|
293
|
-
return server;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
#RequestVote = (service: IServiceDetail) => {
|
|
297
|
-
const options: jayson.TcpClientOptions = {
|
|
298
|
-
port: service.port,
|
|
299
|
-
host: service.host
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
const client = jayson.client.tls(options);
|
|
303
|
-
|
|
304
|
-
let lastLogItem: ILogItem;
|
|
305
|
-
if (this.#log.length > 0) {
|
|
306
|
-
lastLogItem = this.#log[this.#log.length-1];
|
|
307
|
-
} else {
|
|
308
|
-
lastLogItem = {
|
|
309
|
-
term: 0,
|
|
310
|
-
index: 0,
|
|
311
|
-
data: null
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
client.request('vote', [ this.#currentTerm, lastLogItem.term, lastLogItem.index ], (error: any, response: any) => {
|
|
316
|
-
if (error) {
|
|
317
|
-
//this.#LogInfoMessage(chalk.red(`vote attempt fail: [${JSON.stringify(options)}: ${error}]`));
|
|
318
|
-
} else {
|
|
319
|
-
// Log the result
|
|
320
|
-
if (response.result === true) {
|
|
321
|
-
this.#votes[this.#GetServiceKey(service)] = 1;
|
|
322
|
-
}
|
|
323
|
-
this.#CheckMajority();
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
#AppendEntry = (service: IServiceDetail) => {
|
|
329
|
-
const options: jayson.TcpClientOptions = {
|
|
330
|
-
port: service.port,
|
|
331
|
-
host: service.host
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
const client = jayson.client.tls(options);
|
|
335
|
-
|
|
336
|
-
let lastLogItem: ILogItem;
|
|
337
|
-
if (this.#log.length > 0) {
|
|
338
|
-
lastLogItem = this.#log[this.#log.length-1];
|
|
339
|
-
} else {
|
|
340
|
-
lastLogItem = {
|
|
341
|
-
term: 0,
|
|
342
|
-
index: 0,
|
|
343
|
-
data: null
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
client.request('appendEntry', [ this.#thisService.host, this.#thisService.port, this.#currentTerm, lastLogItem.term, lastLogItem.index ], (error: any, response: any) => {
|
|
348
|
-
if (error) {
|
|
349
|
-
//this.#LogInfoMessage(chalk.red(`appendEntry attempt fail: [${JSON.stringify(options)}: ${error}]`));
|
|
350
|
-
} else {
|
|
351
|
-
this.#appendedEntries[this.#GetServiceKey(service)] = 1;
|
|
352
|
-
// Log the result
|
|
353
|
-
/*
|
|
354
|
-
if (response.result === true) {
|
|
355
|
-
this.#votes[this.#GetServiceKey(service)] = 1;
|
|
356
|
-
}
|
|
357
|
-
*/
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
#AppendEntries = () => {
|
|
363
|
-
// Reset all appendEntries for this iteration
|
|
364
|
-
this.#appendedEntries = { };
|
|
365
|
-
|
|
366
|
-
// Reset all votes
|
|
367
|
-
this.#services.forEach((service, index) => {
|
|
368
|
-
this.#appendedEntries[this.#GetServiceKey(service)] = 0;
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
// Request vote for all other services - include my logs current item
|
|
372
|
-
this.#services.forEach((service, index) => {
|
|
373
|
-
if (service.host.localeCompare(this.#thisService.host) === 0 && service.port === this.#thisService.port) {
|
|
374
|
-
// Myself
|
|
375
|
-
this.#ResetElectionTimeout();
|
|
376
|
-
this.#appendedEntries[this.#GetSelfServiceKey()] = 1;
|
|
377
|
-
} else {
|
|
378
|
-
// Send vote request
|
|
379
|
-
this.#AppendEntry(service);
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
#GetServiceKey = (service: IServiceDetail) => {
|
|
385
|
-
return `${service.host}:${service.port}`;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
#GetSelfServiceKey = () => {
|
|
389
|
-
return this.#GetServiceKey(this.#thisService);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
// set interval ???
|
|
393
|
-
#StartAppendEntries = () => {
|
|
394
|
-
this.#AppendEntries();
|
|
395
|
-
setTimeout(() => {
|
|
396
|
-
// Now check if we still have majority
|
|
397
|
-
const majority: boolean = this.#CheckMajorityWithCollection(this.#appendedEntries);
|
|
398
|
-
if (majority) {
|
|
399
|
-
this.#StartAppendEntries();
|
|
400
|
-
} else {
|
|
401
|
-
this.#LogInfoMessage(chalk.red(`${this.#GetLogPrefix()}: Not enough response for valid cluster state.`));
|
|
402
|
-
}
|
|
403
|
-
}, this.#heartBeatTimeout).unref();
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
#Promote = () => {
|
|
407
|
-
this.#ChangeState(AppMasterRAFTState.LEADER);
|
|
408
|
-
this.#LogInfoMessage(chalk.green(`${this.#GetLogPrefix()}: New LEADER is elected: [${this.#GetSelfServiceKey()}]`));
|
|
409
|
-
// As leader, now start the regular pings
|
|
410
|
-
this.#StartAppendEntries();
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
#CheckMajority = () => {
|
|
414
|
-
if (this.#CheckMajorityWithCollection(this.#votes)) {
|
|
415
|
-
this.#Promote();
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
#CheckMajorityWithCollection = (col: JSONObject): boolean => {
|
|
420
|
-
let votes = 0;
|
|
421
|
-
for (const [key, val] of Object.entries(col)) {
|
|
422
|
-
votes += val;
|
|
423
|
-
}
|
|
424
|
-
const requiredVotes = Math.floor(this.#services.length / 2) + 1;
|
|
425
|
-
|
|
426
|
-
if (requiredVotes !== this.#lastRequiredVotes || votes !== this.#lastVotes) {
|
|
427
|
-
this.#LogInfoMessage(chalk.cyan(`${this.#GetLogPrefix()}votes: [${votes} need: [${requiredVotes}]`));
|
|
428
|
-
this.#lastRequiredVotes = requiredVotes;
|
|
429
|
-
this.#lastVotes = votes;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
return votes >= requiredVotes;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
#StartCanidateVote = () => {
|
|
436
|
-
|
|
437
|
-
// Get the election timeout going again
|
|
438
|
-
this.#StartElectionTimeout();
|
|
439
|
-
|
|
440
|
-
this.#LogInfoMessage(chalk.yellow(`${this.#GetLogPrefix()}: Start CANDIDATE vote`));
|
|
441
|
-
// Start in the CANDIDATE state
|
|
442
|
-
this.#ChangeState(AppMasterRAFTState.CANDIDATE);
|
|
443
|
-
// Reset votes
|
|
444
|
-
this.#votes = { };
|
|
445
|
-
|
|
446
|
-
// Reset all votes from all service instances
|
|
447
|
-
this.#services.forEach((service, index) => {
|
|
448
|
-
this.#votes[this.#GetServiceKey(service)] = 0;
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
// Start a new term
|
|
452
|
-
this.#currentTerm++;
|
|
453
|
-
|
|
454
|
-
// Request vote for all other services - include my logs current item
|
|
455
|
-
this.#services.forEach((service, index) => {
|
|
456
|
-
if (service.host.localeCompare(this.#thisService.host) === 0 && service.port === this.#thisService.port) {
|
|
457
|
-
// Log the fact that I have now voted for this term
|
|
458
|
-
this.#votedLog[this.#currentTerm] = true;
|
|
459
|
-
// Log the result - Vote for myself
|
|
460
|
-
this.#votes[this.#GetSelfServiceKey()] = 1;
|
|
461
|
-
// Return my yes vote
|
|
462
|
-
this.#LogInfoMessage(chalk.green(`${this.#GetLogPrefix()}: SELF VOTE: canidate currentTerm: [${this.#currentTerm}], vote YES`));
|
|
463
|
-
this.#CheckMajority();
|
|
464
|
-
} else {
|
|
465
|
-
// Send vote request
|
|
466
|
-
this.#RequestVote(service);
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
#ResetElectionTimeout = () => {
|
|
472
|
-
if (this.#canidateTimeout) {
|
|
473
|
-
clearTimeout(this.#canidateTimeout);
|
|
474
|
-
}
|
|
475
|
-
this.#StartElectionTimeout();
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
#StartElectionTimeout = () => {
|
|
479
|
-
if (this.#canidateTimeout) {
|
|
480
|
-
clearTimeout(this.#canidateTimeout);
|
|
481
|
-
}
|
|
482
|
-
this.#canidateTimeout = setTimeout(() => {
|
|
483
|
-
this.#StartCanidateVote();
|
|
484
|
-
}, this.#electionTimeout).unref();
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
#StartRAFTService = async () => {
|
|
488
|
-
this.LogInfoMessage(chalk.green(`---[ RAFT Protocol Starting ]---`));
|
|
489
|
-
await this.#SetupJSONRPCServer();
|
|
490
|
-
this.#StartElectionTimeout();
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
#ChangeState(newState: AppMasterRAFTState) {
|
|
494
|
-
this.LogInfoMessage(chalk.magenta(`${this.#GetLogPrefix()}: State Change, From: [${this.#RAFTState.toString()}] --> To: [${newState.toString()}]`));
|
|
495
|
-
this.#RAFTState = newState;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
MasterStarted(): void {
|
|
499
|
-
setTimeout(() => {
|
|
500
|
-
this.#StartRAFTService();
|
|
501
|
-
}, this.#startRAFTProtocolTimeout).unref();
|
|
502
|
-
}
|
|
503
|
-
}
|