node-pm2-events
Advanced tools
Comparing version 1.2.29 to 1.2.31
{ | ||
"name": "node-pm2-events", | ||
"version": "1.2.29", | ||
"description": "Local and decentralized instances eventbus with web socket addon", | ||
"version": "1.2.31", | ||
"description": "EventBus for local and decentralized instances of the both for individual nodejs applications and as parts of pm2", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -11,3 +11,3 @@ ## 🇺🇦Decentralized instances events | ||
```ecmascript 6 | ||
```javascript | ||
process.on('message', async function (packet) { | ||
@@ -27,3 +27,3 @@ /* do something with packet.data */ | ||
```ecmascript 6 | ||
```javascript | ||
const EventBus = require('node-pm2-events'); | ||
@@ -34,3 +34,3 @@ ``` | ||
```ecmascript 6 | ||
```javascript | ||
// internal events | ||
@@ -46,3 +46,3 @@ EventBus.on('channelName', (m) => { | ||
```ecmascript 6 | ||
```javascript | ||
const Config = { | ||
@@ -71,3 +71,3 @@ redis: { | ||
```ecmascript 6 | ||
```javascript | ||
// execute on one server and on some other(s) | ||
@@ -89,3 +89,3 @@ await EventBus.transport | ||
* Add [fastify web socket plugin](https://github.com/fastify/fastify-websocket) | ||
```ecmascript 6 | ||
```javascript | ||
const fastify = require('fastify')({ | ||
@@ -115,3 +115,3 @@ logger: {level: Config.isDev ? 'info' : 'warn'}, | ||
> local events will be relayed to your websocket connections and to decentralized servers as well | ||
```ecmascript 6 | ||
```javascript | ||
//... | ||
@@ -136,3 +136,3 @@ const routes = []; | ||
[](https://github.com/rosbitskyy/node-pm2-events/blob/main/main-srv-test.js) | ||
```ecmascript 6 | ||
```javascript | ||
// override: handle messages from clients sockets | ||
@@ -168,3 +168,3 @@ EventBus.websocket.messagesHandler = (message, session, connection) => { | ||
```ecmascript 6 | ||
```javascript | ||
await EventBus.transport.initialize(Config.redis) | ||
@@ -177,3 +177,3 @@ .filterByProcessName(false) | ||
```ecmascript 6 | ||
```javascript | ||
// Somewhere, in the place you need | ||
@@ -195,3 +195,3 @@ EventBus.transport.onMasterChange((isMain) => { | ||
```ecmascript 6 | ||
```javascript | ||
await EventBus.transport.initialize(Config.redis) | ||
@@ -221,3 +221,5 @@ .filterByProcessName(false) | ||
desired process. | ||
> EventBus.transport.filterByProcessName(true) | ||
```javascript | ||
EventBus.transport.filterByProcessName(true) | ||
``` | ||
@@ -238,3 +240,5 @@ #### PM2 processes list | ||
entity of the microservices ecosystem, turn off filtering by process name: | ||
> EventBus.transport.filterByProcessName(false) | ||
```javascript | ||
EventBus.transport.filterByProcessName(false) | ||
``` | ||
@@ -241,0 +245,0 @@ ### Dependencies |
31798
235