@weave-js/core 0.10.0 → 0.12.0

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 (132) hide show
  1. package/.eslintrc.js +1 -1
  2. package/jest.config.js +1 -1
  3. package/lib/ExtendableError.js +33 -0
  4. package/lib/broker/context.js +58 -46
  5. package/lib/broker/{default-options.js → defaultOptions.js} +31 -13
  6. package/lib/broker/index.js +273 -251
  7. package/lib/buildRuntime.js +70 -0
  8. package/lib/cache/adapters/base.js +119 -0
  9. package/lib/cache/adapters/inMemory.js +154 -0
  10. package/lib/cache/adapters/inMemoryLru.js +140 -0
  11. package/lib/cache/adapters/index.js +10 -0
  12. package/lib/cache/getCacheKeyByObject.js +31 -0
  13. package/lib/cache/getPropertyFromDataOrMetadata.js +20 -0
  14. package/lib/cache/lock.js +34 -11
  15. package/lib/constants.js +11 -8
  16. package/lib/{error-handler.js → errorHandler.js} +8 -8
  17. package/lib/errors.js +46 -39
  18. package/lib/helper/{define-action.js → defineAction.js} +5 -3
  19. package/lib/helper/{define-broker-options.js → defineBrokerOptions.js} +4 -2
  20. package/lib/helper/{define-service.js → defineService.js} +6 -3
  21. package/lib/index.js +25 -22
  22. package/lib/logger/base.js +38 -29
  23. package/lib/logger/format/asHumanReadable.js +15 -14
  24. package/lib/logger/format/asJson.js +10 -10
  25. package/lib/logger/format/index.js +3 -3
  26. package/lib/logger/index.js +28 -25
  27. package/lib/logger/levels.js +23 -22
  28. package/lib/logger/tools.js +17 -13
  29. package/lib/logger/utils/colorize.js +23 -23
  30. package/lib/logger/utils/format.js +89 -65
  31. package/lib/metrics/common.js +47 -47
  32. package/lib/metrics/constants.js +44 -44
  33. package/lib/metrics/exporter/base.js +8 -8
  34. package/lib/metrics/exporter/event.js +20 -20
  35. package/lib/metrics/exporter/index.js +15 -15
  36. package/lib/metrics/index.js +2 -2
  37. package/lib/metrics/types/base.js +20 -20
  38. package/lib/metrics/types/counter.js +6 -6
  39. package/lib/metrics/types/gauge.js +24 -24
  40. package/lib/metrics/types/histogram.js +26 -26
  41. package/lib/metrics/types/index.js +6 -6
  42. package/lib/metrics/types/info.js +17 -17
  43. package/lib/middlewares/action-hooks/index.js +82 -34
  44. package/lib/middlewares/bulkhead/index.js +34 -33
  45. package/lib/middlewares/cache/index.js +106 -0
  46. package/lib/middlewares/circuit-breaker/index.js +85 -60
  47. package/lib/middlewares/context-tracker/index.js +39 -39
  48. package/lib/middlewares/error-handler/index.js +14 -14
  49. package/lib/middlewares/index.js +3 -2
  50. package/lib/middlewares/metrics/getMiddlewareWrapper.js +17 -17
  51. package/lib/middlewares/metrics/index.js +29 -29
  52. package/lib/middlewares/retry/index.js +15 -15
  53. package/lib/middlewares/timeout/index.js +18 -18
  54. package/lib/middlewares/tracing/index.js +50 -37
  55. package/lib/middlewares/tracing/tags.js +43 -0
  56. package/lib/middlewares/validator/index.js +32 -32
  57. package/lib/registry/{action-endpoint.js → actionEndpoint.js} +8 -8
  58. package/lib/registry/collections/{action-collection.js → actionCollection.js} +39 -35
  59. package/lib/registry/collections/{endpoint-collection.js → endpointCollection.js} +64 -65
  60. package/lib/registry/collections/{event-collection.js → eventCollection.js} +65 -69
  61. package/lib/registry/collections/{node-collection.js → nodeCollection.js} +45 -45
  62. package/lib/registry/collections/{service-collection.js → serviceCollection.js} +61 -55
  63. package/lib/registry/eventEndpoint.js +26 -0
  64. package/lib/registry/load-balancer/base.js +3 -3
  65. package/lib/registry/load-balancer/index.js +7 -7
  66. package/lib/registry/node.js +27 -27
  67. package/lib/registry/registry.js +147 -163
  68. package/lib/registry/service/parseAction.js +16 -16
  69. package/lib/registry/service/parseEvent.js +18 -18
  70. package/lib/registry/service/reduceMixins.js +10 -10
  71. package/lib/registry/service/service.js +72 -72
  72. package/lib/registry/{service-item.js → serviceItem.js} +21 -21
  73. package/lib/runtime/{init-action-invoker.js → initActionInvoker.js} +21 -21
  74. package/lib/runtime/initCache.js +19 -0
  75. package/lib/runtime/{init-context-factory.js → initContextFactory.js} +22 -22
  76. package/lib/runtime/{init-eventbus.js → initEventbus.js} +54 -53
  77. package/lib/runtime/{init-logger.js → initLogger.js} +11 -11
  78. package/lib/runtime/{init-metrics.js → initMetrics.js} +55 -54
  79. package/lib/runtime/{init-middleware-manager.js → initMiddlewareManager.js} +21 -21
  80. package/lib/runtime/{init-registry.js → initRegistry.js} +6 -6
  81. package/lib/runtime/initServiceManager.js +145 -0
  82. package/lib/runtime/{init-tracing.js → initTracing.js} +25 -24
  83. package/lib/runtime/{init-transport.js → initTransport.js} +5 -5
  84. package/lib/runtime/{init-uuid-factory.js → initUuidFactory.js} +4 -4
  85. package/lib/runtime/{init-validator.js → initValidator.js} +5 -5
  86. package/lib/tracing/collectors/base.js +29 -37
  87. package/lib/tracing/collectors/event.js +33 -33
  88. package/lib/tracing/collectors/index.js +16 -16
  89. package/lib/tracing/span.js +34 -32
  90. package/lib/tracing/time.js +8 -8
  91. package/lib/transport/InboundTransformStream.js +75 -0
  92. package/lib/transport/adapters/adapteBase.js +107 -0
  93. package/lib/transport/adapters/adapters.js +4 -4
  94. package/lib/transport/adapters/dummy/index.js +19 -19
  95. package/lib/transport/adapters/fromURI.js +13 -13
  96. package/lib/transport/adapters/getAdapterByName.js +5 -5
  97. package/lib/transport/adapters/index.js +12 -12
  98. package/lib/transport/adapters/tcp/discovery/codec.js +4 -4
  99. package/lib/transport/adapters/tcp/discovery/index.js +90 -76
  100. package/lib/transport/adapters/tcp/index.js +180 -175
  101. package/lib/transport/adapters/tcp/tcp-messagetypes.js +7 -7
  102. package/lib/transport/adapters/tcp/tcpReader.js +39 -38
  103. package/lib/transport/adapters/tcp/tcpWriteStream.js +26 -26
  104. package/lib/transport/adapters/tcp/tcpWriter.js +58 -58
  105. package/lib/transport/adapters/tcp/utils.js +12 -12
  106. package/lib/transport/createMessage.js +11 -0
  107. package/lib/transport/createTransport.js +377 -334
  108. package/lib/transport/errorPayloadFactory.js +15 -0
  109. package/lib/transport/messageHandlers.js +517 -0
  110. package/lib/transport/messageTypes.js +23 -0
  111. package/lib/types.js +95 -71
  112. package/lib/utils/index.js +2 -2
  113. package/lib/utils/options.js +47 -45
  114. package/lib/utils/{restore-error.js → restoreError.js} +4 -4
  115. package/package.json +6 -12
  116. package/CHANGELOG.md +0 -1334
  117. package/lib/build-runtime.js +0 -70
  118. package/lib/cache/base.js +0 -142
  119. package/lib/cache/index.js +0 -48
  120. package/lib/cache/memory.js +0 -121
  121. package/lib/middlewares/tracing/buildTags.js +0 -17
  122. package/lib/new-errors.js +0 -25
  123. package/lib/registry/event-endpoint.js +0 -26
  124. package/lib/runtime/init-cache.js +0 -10
  125. package/lib/runtime/init-service-manager.js +0 -128
  126. package/lib/tracing/collectors/console.js +0 -34
  127. package/lib/tracing/index.js +0 -3
  128. package/lib/tracing/tracer.js +0 -64
  129. package/lib/transport/adapters/adapter-base.js +0 -92
  130. package/lib/transport/message-handlers.js +0 -448
  131. package/lib/transport/message-types.js +0 -59
  132. package/lib/transport/message.js +0 -16
@@ -1,7 +1,7 @@
1
1
  // @ts-check
2
2
 
3
3
  /*
4
- * Author: Kevin Ries (kevin@fachw3rk.de)
4
+ * Author: Kevin Ries (kevin.ries@fachwerk.io)
5
5
  * -----
6
6
  * Copyright 2021 Fachwerk
7
7
  */
@@ -11,88 +11,88 @@
11
11
  * @typedef {import('../../types.js').NodeCollection} NodeCollection
12
12
  */
13
13
 
14
- const { getIpList, omit } = require('@weave-js/utils')
15
- const { createNode } = require('../node')
14
+ const { getIpList, omit } = require('@weave-js/utils');
15
+ const { createNode } = require('../node');
16
16
  /**
17
17
  * Create node collection
18
18
  * @param {Registry} registry Registry reference
19
19
  * @return {NodeCollection} Node collection
20
20
  */
21
21
  exports.createNodeCollection = (registry) => {
22
- const nodeCollection = Object.create(null)
23
- const { runtime } = registry
24
- const nodes = new Map()
22
+ const nodeCollection = Object.create(null);
23
+ const { runtime } = registry;
24
+ const nodes = new Map();
25
25
 
26
- nodeCollection.localNode = null
26
+ nodeCollection.localNode = null;
27
27
 
28
28
  nodeCollection.createNode = (nodeId) => {
29
- return createNode(nodeId)
30
- }
29
+ return createNode(nodeId);
30
+ };
31
31
 
32
32
  nodeCollection.add = (id, node) => {
33
- nodes.set(id, node)
34
- }
33
+ nodes.set(id, node);
34
+ };
35
35
 
36
36
  nodeCollection.has = (id) => {
37
- return nodes.has(id)
38
- }
37
+ return nodes.has(id);
38
+ };
39
39
 
40
40
  nodeCollection.get = (id) => {
41
- return nodes.get(id)
42
- }
41
+ return nodes.get(id);
42
+ };
43
43
 
44
44
  nodeCollection.remove = (id) => {
45
- return nodes.delete(id)
46
- }
45
+ return nodes.delete(id);
46
+ };
47
47
 
48
48
  nodeCollection.list = ({ withServices = true } = {}) => {
49
- const result = []
49
+ const result = [];
50
50
  nodes.forEach(node => {
51
51
  if (withServices) {
52
- result.push(omit(node, ['info']))
52
+ result.push(omit(node, ['info']));
53
53
  } else {
54
- result.push(omit(node, ['info', 'services']))
54
+ result.push(omit(node, ['info', 'services']));
55
55
  }
56
- })
57
- return result
58
- }
56
+ });
57
+ return result;
58
+ };
59
59
 
60
60
  nodeCollection.disconnected = (nodeId, isUnexpected) => {
61
- const node = nodes.get(nodeId)
61
+ const node = nodes.get(nodeId);
62
62
  if (node && node.isAvailable) {
63
- registry.deregisterServiceByNodeId(node.id)
64
- node.disconnected(isUnexpected)
65
- runtime.eventBus.broadcastLocal('$node.disconnected', nodeId, isUnexpected)
66
- registry.log.warn(`Node '${node.id}'${isUnexpected ? ' unexpectedly' : ''} disconnected.`)
63
+ registry.deregisterServiceByNodeId(node.id);
64
+ node.disconnected(isUnexpected);
65
+ runtime.eventBus.broadcastLocal('$node.disconnected', nodeId, isUnexpected);
66
+ registry.log.warn(`Node '${node.id}'${isUnexpected ? ' unexpectedly' : ''} disconnected.`);
67
67
  }
68
- }
68
+ };
69
69
 
70
70
  nodeCollection.toArray = () => {
71
- const result = []
72
- nodes.forEach(node => result.push(node))
73
- return result
74
- }
71
+ const result = [];
72
+ nodes.forEach(node => result.push(node));
73
+ return result;
74
+ };
75
75
 
76
76
  // get Local node information and add it to the collection by
77
77
  const addLocalNode = () => {
78
- const node = createNode(runtime.options.nodeId)
78
+ const node = createNode(runtime.options.nodeId);
79
79
 
80
- node.isLocal = true
81
- node.IPList = getIpList()
80
+ node.isLocal = true;
81
+ node.IPList = getIpList();
82
82
  node.client = {
83
83
  type: 'nodejs',
84
84
  version: runtime.version,
85
85
  langVersion: process.version
86
- }
86
+ };
87
87
 
88
- node.sequence = 1
89
- nodeCollection.add(node.id, node)
90
- nodeCollection.localNode = node
88
+ node.sequence = 1;
89
+ nodeCollection.add(node.id, node);
90
+ nodeCollection.localNode = node;
91
91
 
92
- return node
93
- }
92
+ return node;
93
+ };
94
94
 
95
- addLocalNode()
95
+ addLocalNode();
96
96
 
97
- return nodeCollection
98
- }
97
+ return nodeCollection;
98
+ };
@@ -1,7 +1,7 @@
1
1
  // @ts-check
2
2
 
3
3
  /*
4
- * Author: Kevin Ries (kevin@fachw3rk.de)
4
+ * Author: Kevin Ries (kevin.ries@fachwerk.io)
5
5
  * -----
6
6
  * Copyright 2021 Fachwerk
7
7
  */
@@ -12,8 +12,8 @@
12
12
  */
13
13
 
14
14
  // const { createEndpointCollection } = require('./endpoint-collection')
15
- const { omit, remove } = require('@weave-js/utils')
16
- const { createServiceItem } = require('../service-item')
15
+ const { omit, remove } = require('@weave-js/utils');
16
+ const { createServiceItem } = require('../serviceItem');
17
17
 
18
18
  /**
19
19
  * Service collection factory
@@ -22,10 +22,10 @@ const { createServiceItem } = require('../service-item')
22
22
  */
23
23
  exports.createServiceCollection = (registry) => {
24
24
  /** @type {ServiceCollection} */
25
- const serviceCollection = Object.create(null)
26
- const { runtime } = registry
27
- const services = serviceCollection.services = []
28
- const actions = new Map()
25
+ const serviceCollection = Object.create(null);
26
+ const { runtime } = registry;
27
+ const services = serviceCollection.services = [];
28
+ const actions = new Map();
29
29
  // const options = broker.options
30
30
 
31
31
  // const findServiceByNode = (nodeId, name) => {
@@ -33,65 +33,71 @@ exports.createServiceCollection = (registry) => {
33
33
  // }
34
34
 
35
35
  serviceCollection.add = (node, name, version, settings) => {
36
- const item = createServiceItem(node, name, version, settings, node.id === runtime.nodeId)
37
- services.push(item)
38
- return item
39
- }
36
+ const item = createServiceItem(node, name, version, settings, node.id === runtime.nodeId);
37
+ services.push(item);
38
+ return item;
39
+ };
40
40
 
41
- serviceCollection.get = (nodeId, name, version) => services.find(svc => svc.equals(name, version, nodeId))
41
+ serviceCollection.get = (nodeId, name, version) => services.find(svc => svc.equals(name, version, nodeId));
42
42
 
43
43
  serviceCollection.has = (name, version, nodeId) => {
44
- return !!services.find(svc => svc.equals(name, version, nodeId))
45
- }
44
+ return !!services.find(svc => svc.equals(name, version, nodeId));
45
+ };
46
46
 
47
47
  serviceCollection.remove = (nodeId, name, version) => {
48
- const service = serviceCollection.get(nodeId, name, version)
48
+ const service = serviceCollection.get(nodeId, name, version);
49
49
 
50
50
  if (service) {
51
- registry.actionCollection.removeByService(service)
52
- registry.eventCollection.removeByService(service)
53
- remove(services, svc => svc === service)
51
+ registry.actionCollection.removeByService(service);
52
+ registry.eventCollection.removeByService(service);
53
+ remove(services, svc => svc === service);
54
54
  }
55
- }
55
+ };
56
56
 
57
57
  serviceCollection.removeAllByNodeId = (nodeId) => {
58
58
  remove(services, service => {
59
59
  if (service.node.id === nodeId) {
60
- registry.actionCollection.removeByService(service)
61
- registry.eventCollection.removeByService(service)
62
- return true
60
+ registry.actionCollection.removeByService(service);
61
+ registry.eventCollection.removeByService(service);
62
+ return true;
63
63
  }
64
- return false
65
- })
66
- }
64
+ return false;
65
+ });
66
+ };
67
67
 
68
- serviceCollection.tryFindActionsByActionName = (actionName) => actions.get(actionName)
68
+ serviceCollection.tryFindActionsByActionName = (actionName) => actions.get(actionName);
69
69
 
70
70
  serviceCollection.getActionsList = () => {
71
- const result = []
71
+ const result = [];
72
72
  actions.forEach((action, key) => {
73
73
  const item = {
74
74
  name: key,
75
75
  count: action.count(),
76
76
  hasLocal: action.hasLocal()
77
- }
78
- result.push(item)
79
- })
80
- return result
81
- }
82
-
83
- serviceCollection.list = ({ localOnly = false, withActions = false, withEvents = false, withNodeService = false, withSettings = false }) => {
84
- const result = []
77
+ };
78
+ result.push(item);
79
+ });
80
+ return result;
81
+ };
82
+
83
+ serviceCollection.list = ({
84
+ localOnly = false,
85
+ withActions = false,
86
+ withEvents = false,
87
+ withNodeService = false,
88
+ withSettings = false
89
+ } = {}) => {
90
+ const result = [];
85
91
  services.forEach((service) => {
86
92
  if (/^\$node/.test(service.name) && !withNodeService) {
87
- return
93
+ return;
88
94
  }
89
95
  if (service.settings && service.settings.$private) {
90
- return
96
+ return;
91
97
  }
92
98
 
93
99
  if (localOnly && !service.isLocal) {
94
- return
100
+ return;
95
101
  }
96
102
 
97
103
  const item = {
@@ -99,39 +105,39 @@ exports.createServiceCollection = (registry) => {
99
105
  nodeId: service.node.id,
100
106
  version: service.version,
101
107
  isAvailable: service.node.isAvailable
102
- }
108
+ };
103
109
 
104
110
  if (withSettings) {
105
- item.settings = service.settings
111
+ item.settings = service.settings;
106
112
  }
107
113
 
108
114
  if (withActions) {
109
- item.actions = {}
115
+ item.actions = {};
110
116
  Object.values(service.actions)
111
117
  .forEach(action => {
112
- item.actions[action.name] = omit(action, ['handler', 'service'])
113
- })
118
+ item.actions[action.name] = omit(action, ['handler', 'service']);
119
+ });
114
120
  }
115
121
 
116
122
  if (withEvents) {
117
- item.events = {}
123
+ item.events = {};
118
124
  Object.values(service.events)
119
125
  .forEach(event => {
120
- item.events[event.name] = omit(event, ['service', 'handler'])
121
- })
126
+ item.events[event.name] = omit(event, ['service', 'handler']);
127
+ });
122
128
  }
123
129
 
124
- result.push(item)
125
- })
126
- return result
127
- }
130
+ result.push(item);
131
+ });
132
+ return result;
133
+ };
128
134
 
129
135
  serviceCollection.findEndpointByNodeId = (actionName, nodeId) => {
130
- const endpointListItem = serviceCollection.tryFindActionsByActionName(actionName)
136
+ const endpointListItem = serviceCollection.tryFindActionsByActionName(actionName);
131
137
  if (endpointListItem) {
132
- return endpointListItem.endpointByNodeId(nodeId)
138
+ return endpointListItem.endpointByNodeId(nodeId);
133
139
  }
134
- }
140
+ };
135
141
 
136
- return serviceCollection
137
- }
142
+ return serviceCollection;
143
+ };
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Author: Kevin Ries (kevin.ries@fachwerk.io)
3
+ * -----
4
+ * Copyright 2021 Fachwerk
5
+ */
6
+
7
+ exports.createEventEndpoint = (broker, node, service, event) => {
8
+ const eventEndpoint = Object.create(null);
9
+
10
+ eventEndpoint.node = node;
11
+ eventEndpoint.service = service;
12
+ eventEndpoint.action = event;
13
+ eventEndpoint.isLocal = eventEndpoint.node.id === broker.nodeId;
14
+ eventEndpoint.state = true;
15
+ eventEndpoint.name = `${node.id}:${event.name}`;
16
+
17
+ eventEndpoint.updateEvent = (newEvent) => {
18
+ eventEndpoint.action = newEvent;
19
+ };
20
+
21
+ eventEndpoint.isAvailable = () => {
22
+ return eventEndpoint.state;
23
+ };
24
+
25
+ return eventEndpoint;
26
+ };
@@ -1,7 +1,7 @@
1
1
  module.exports = (broker, registry) => {
2
2
  return {
3
3
  next (/* endpointList,context*/) {
4
- broker.handleError(new Error('Method not implemented!'))
4
+ broker.handleError(new Error('Method not implemented!'));
5
5
  }
6
- }
7
- }
6
+ };
7
+ };
@@ -1,22 +1,22 @@
1
1
  const Strategies = {
2
2
  Random: require('./random'),
3
3
  RoundRobin: require('./round-robin')
4
- }
4
+ };
5
5
  const getByName = name => {
6
6
  if (!name) {
7
- return null
7
+ return null;
8
8
  }
9
9
 
10
- const n = Object.keys(Strategies).find(n => n.toLowerCase() === name.toLowerCase())
10
+ const n = Object.keys(Strategies).find(n => n.toLowerCase() === name.toLowerCase());
11
11
  if (n) {
12
- return this.Cache[n]
12
+ return this.Cache[n];
13
13
  }
14
- }
14
+ };
15
15
 
16
16
  module.exports = {
17
17
  resolve (option) {
18
18
  if (typeof option === 'string') {
19
- return getByName(option)
19
+ return getByName(option);
20
20
  }
21
21
  }
22
- }
22
+ };
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Author: Kevin Ries (kevin@fachw3rk.de)
2
+ * Author: Kevin Ries (kevin.ries@fachwerk.io)
3
3
  * -----
4
4
  * Copyright 2021 Fachwerk
5
5
  */
@@ -8,7 +8,7 @@
8
8
  * @typedef {import('../types.js').Node} Node
9
9
  */
10
10
 
11
- const { cpuUsage } = require('@weave-js/utils')
11
+ const { cpuUsage } = require('@weave-js/utils');
12
12
 
13
13
  /**
14
14
  * Node factory
@@ -38,53 +38,53 @@ exports.createNode = (nodeId) => {
38
38
  events: null,
39
39
  IPList: [],
40
40
  update (payload, isReconnected) {
41
- const newSequence = payload.sequence || 1
41
+ const newSequence = payload.sequence || 1;
42
42
 
43
- this.services = payload.services
44
- this.events = payload.events
45
- this.client = payload.client || {}
46
- this.IPList = payload.IPList || []
47
- this.info = payload
43
+ this.services = payload.services;
44
+ this.events = payload.events;
45
+ this.client = payload.client || {};
46
+ this.IPList = payload.IPList || [];
47
+ this.info = payload;
48
48
 
49
49
  if ((newSequence > this.sequence) || isReconnected === true) {
50
- this.sequence = newSequence
51
- this.offlineTime = null
50
+ this.sequence = newSequence;
51
+ this.offlineTime = null;
52
52
 
53
- return true
53
+ return true;
54
54
  }
55
- return false
55
+ return false;
56
56
  },
57
57
  updateLocalInfo () {
58
58
  cpuUsage().then(result => {
59
- const newVal = Math.round(result.avg)
59
+ const newVal = Math.round(result.avg);
60
60
 
61
61
  if (this.cpu !== newVal) {
62
- this.cpu = Math.round(result.avg)
63
- this.cpuSequence++
62
+ this.cpu = Math.round(result.avg);
63
+ this.cpuSequence++;
64
64
  }
65
- })
65
+ });
66
66
  },
67
67
  heartbeat (payload) {
68
68
  if (!this.isAvailable) {
69
- this.isAvailable = true
70
- this.offlineTime = null
69
+ this.isAvailable = true;
70
+ this.offlineTime = null;
71
71
  }
72
72
 
73
73
  if (payload.cpu !== null) {
74
- this.cpu = payload.cpu
75
- this.cpuSequence = payload.cpuSequence || 1
74
+ this.cpu = payload.cpu;
75
+ this.cpuSequence = payload.cpuSequence || 1;
76
76
  }
77
77
 
78
- this.lastHeartbeatTime = Date.now()
78
+ this.lastHeartbeatTime = Date.now();
79
79
  },
80
80
  disconnected (isUnexpected = false) {
81
81
  if (this.isAvailable) {
82
- this.offlineTime = Date.now()
83
- this.sequence++
84
- this.isUnexpectedDisconnected = isUnexpected
82
+ this.offlineTime = Date.now();
83
+ this.sequence++;
84
+ this.isUnexpectedDisconnected = isUnexpected;
85
85
  }
86
86
 
87
- this.isAvailable = false
87
+ this.isAvailable = false;
88
88
  }
89
- }
90
- }
89
+ };
90
+ };