@weave-js/core 0.14.1 → 0.15.1

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.
@@ -58,7 +58,7 @@ exports.getDefaultOptions = () => {
58
58
  handleBackpressure: true
59
59
  }
60
60
  },
61
- errorHandler: null,
61
+ errorHandler: undefined,
62
62
  loadInternalMiddlewares: true,
63
63
  metrics: {
64
64
  enabled: false,
@@ -8,7 +8,7 @@ exports.errorHandler = ({ options }, error) => {
8
8
  exports.fatalErrorHandler = (runtime, message, error, killProcess = true) => {
9
9
  const { options, log } = runtime;
10
10
  if (options.logger.enabled) {
11
- log.fatal(error, message);
11
+ log.fatal({ error }, message);
12
12
  } else {
13
13
  console.error(message, error);
14
14
  }
@@ -7,7 +7,7 @@ module.exports = (runtime) => {
7
7
  context.service._trackedContexts.push(context);
8
8
  } else {
9
9
  // remote actions
10
- context.service._trackedContexts.push(context);
10
+ runtime.state.trackedContexts.push(context);
11
11
  }
12
12
  }
13
13
 
@@ -19,9 +19,9 @@ module.exports = (runtime) => {
19
19
  context.service._trackedContexts.splice(index, 1);
20
20
  }
21
21
  } else {
22
- const index = context.service._trackedContexts.indexOf(context);
22
+ const index = runtime.state.trackedContexts.indexOf(context);
23
23
  if (index !== -1) {
24
- context.service._trackedContexts.splice(index, 1);
24
+ runtime.state.trackedContexts.splice(index, 1);
25
25
  }
26
26
  }
27
27
  }
@@ -85,14 +85,18 @@ exports.createServiceCollection = (registry) => {
85
85
  withActions = false,
86
86
  withEvents = false,
87
87
  withNodeService = false,
88
- withSettings = false
88
+ withSettings = false,
89
+ withPrivate = false
89
90
  } = {}) => {
90
91
  const result = [];
91
92
  services.forEach((service) => {
92
93
  if (/^\$node/.test(service.name) && !withNodeService) {
93
94
  return;
94
95
  }
95
- if (service.settings && service.settings.$private) {
96
+
97
+ const isPrivate = service.settings && service.settings.$private;
98
+
99
+ if (isPrivate && withPrivate === false) {
96
100
  return;
97
101
  }
98
102
 
@@ -104,7 +108,8 @@ exports.createServiceCollection = (registry) => {
104
108
  name: service.name,
105
109
  nodeId: service.node.id,
106
110
  version: service.version,
107
- isAvailable: service.node.isAvailable
111
+ isAvailable: service.node.isAvailable,
112
+ isPrivate
108
113
  };
109
114
 
110
115
  if (withSettings) {
@@ -431,11 +431,12 @@ module.exports = (runtime, transport) => {
431
431
  // todo: check protocol version
432
432
  // todo: check node ID conflict
433
433
 
434
- // if (payload.sender === runtime.nodeId) {
435
- // if (type === MessageTypes.MESSAGE_INFO && payload.instanceId !== runtime.state.instanceId) {
436
- // return runtime.fatalError('Weave broker has detected a node ID conflict. "nodeId" of broker needs to be unique. Broker will be stopped.')
437
- // }
438
- // }
434
+ if (payload.sender === runtime.nodeId) {
435
+ if (type === MessageTypes.MESSAGE_INFO && payload.instanceId !== runtime.state.instanceId) {
436
+ runtime.fatalError(`Weave broker has detected a node ID conflict. "nodeId" of broker needs to be unique, but there is an broker with node ID "${runtime.nodeId}". Broker will be stopped.`);
437
+ return false;
438
+ }
439
+ }
439
440
 
440
441
  switch (type) {
441
442
  case MessageTypes.MESSAGE_DISCOVERY:
package/lib/types.js CHANGED
@@ -626,6 +626,7 @@ const { EventEmitter2: EventEmitter } = require('eventemitter2');
626
626
  * @property {boolean} [withEvents=false] Include events in result.
627
627
  * @property {boolean} [withNodeService=false] Include node service.
628
628
  * @property {boolean} [withSettings=false] Include service settings.
629
+ * @property {boolean} [withPrivate=false] Include private services.
629
630
  */
630
631
 
631
632
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weave-js/core",
3
- "version": "0.14.1",
3
+ "version": "0.15.1",
4
4
  "description": "The core package of weave",
5
5
  "keywords": [
6
6
  "Weave",