🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

ts-cluster-support-decorators

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-cluster-support-decorators

`npm install ts-cluster-support-decorators --save` #Using

0.0.3
latest
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

#Installation npm install ts-cluster-support-decorators --save #Using

Let's say we use routing-controllers, I like it

I run 4 clusters and I need them to synchronize data

 import "reflect-metadata";
 import {createExpressServer} from "routing-controllers";
 import * as cluster from "cluster";
 
 @WatchClusterVar()
 @JsonController('/user')
 class UserController{
     @CommonVar()
     anyVars: number;
     
     @Get('/edit')
     editAnyVar(){
         this.anyVars = Math.random();
         return {
             success: true,
             msg: 'Variable changed'
         }
     }
     
     @WatchVar('anyVars')
     watch(){
         console.log("Update value 'anyVars'", this.anyVars)
     }
 }
 
 if(cluster.isMaster){
     cluster.fork();
     cluster.fork();
     cluster.fork();
     cluster.fork();
 }
 createExpressServer({
     routePrefix: "/api",
     controllers: [UserController]
 }).listen(3000);

Now, when changing anyVars, it will change in all clusters.

Method watch when anyVars will change.

Keywords

watch var

FAQs

Package last updated on 05 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts