pwi-plata-type 0.3.11 → 0.3.12

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.
Files changed (2) hide show
  1. package/libs/cluster.ts +34 -1
  2. package/package.json +1 -1
package/libs/cluster.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { PlataRequire, PlataDirs, PlataFiles } from './tools'
1
+ import { PlataRequire, PlataDirs, PlataFiles, PlataResultado } from './tools'
2
2
  import { cpus } from 'node:os'
3
3
  import * as typeCluster from 'node:cluster'
4
4
 
@@ -169,6 +169,16 @@ export class PlataClusterManager {
169
169
  }
170
170
  }
171
171
 
172
+ private async sendAllWorkers(msg: PlataClusterMsg) {
173
+ if (this.Cluster.workers === undefined) return
174
+
175
+ for (const worker of Object.values(this.Cluster.workers)) {
176
+ if (worker === undefined) continue
177
+
178
+ worker.send(msg)
179
+ }
180
+ }
181
+
172
182
  private async _clusterMsgServer(_worker: typeCluster.Worker, msg: PlataClusterMsg) {
173
183
  if (msg.name !== '_plata') {
174
184
  // TODO :::
@@ -178,7 +188,30 @@ export class PlataClusterManager {
178
188
  console.log('Solicitado kill do app')
179
189
  process.exit(0)
180
190
  ;
191
+ case 'ECHO':
192
+ this.sendAllWorkers(msg.data.msg)
193
+ return
194
+ ;
181
195
  }
182
196
  }
183
197
  }
198
+ }
199
+
200
+ export async function send(msg: PlataClusterMsg): Promise<PlataResultado<boolean>> {
201
+ if (process.send === undefined) {
202
+ return {
203
+ errorID: 'PBLCLWS0001',
204
+ msg: `Erro interno no cluster da plataforma`
205
+ }
206
+ }
207
+
208
+ process.send({
209
+ name: '_plata',
210
+ data: {
211
+ action: 'ECHO',
212
+ msg
213
+ }
214
+ } as PlataClusterMsg)
215
+
216
+ return true
184
217
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pwi-plata-type",
3
- "version": "0.3.11",
3
+ "version": "0.3.12",
4
4
  "main": "index.ts",
5
5
  "bin": {
6
6
  "plata": "bin/plata.ts",