New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Maintainers
1
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc