@weave-js/core 0.9.4 → 0.11.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.
- package/lib/ExtendableError.js +33 -0
- package/lib/broker/context.js +25 -13
- package/lib/broker/{default-options.js → defaultOptions.js} +25 -6
- package/lib/broker/index.js +224 -194
- package/lib/buildRuntime.js +70 -0
- package/lib/cache/adapters/base.js +143 -0
- package/lib/cache/adapters/inMemory.js +154 -0
- package/lib/cache/adapters/inMemoryLru.js +140 -0
- package/lib/cache/adapters/index.js +46 -0
- package/lib/cache/base.js +49 -44
- package/lib/cache/lock.js +21 -4
- package/lib/constants.js +8 -5
- package/lib/errorHandler.js +19 -0
- package/lib/errors.js +17 -10
- package/lib/helper/{define-action.js → defineAction.js} +3 -1
- package/lib/helper/{define-broker-options.js → defineBrokerOptions.js} +2 -0
- package/lib/helper/{define-service.js → defineService.js} +4 -1
- package/lib/index.js +17 -92
- package/lib/logger/format/asHumanReadable.js +4 -3
- package/lib/logger/index.js +7 -1
- package/lib/logger/levels.js +8 -7
- package/lib/logger/tools.js +4 -0
- package/lib/logger/utils/format.js +18 -4
- package/lib/metrics/constants.js +8 -6
- package/lib/metrics/types/gauge.js +1 -1
- package/lib/middlewares/action-hooks/index.js +62 -14
- package/lib/middlewares/bulkhead/index.js +5 -4
- package/lib/middlewares/cache/index.js +106 -0
- package/lib/middlewares/circuit-breaker/index.js +41 -16
- package/lib/middlewares/context-tracker/index.js +3 -3
- package/lib/middlewares/error-handler/index.js +3 -3
- package/lib/middlewares/index.js +2 -1
- package/lib/middlewares/metrics/getMiddlewareWrapper.js +2 -2
- package/lib/middlewares/metrics/index.js +2 -2
- package/lib/middlewares/retry/index.js +11 -10
- package/lib/middlewares/timeout/index.js +5 -5
- package/lib/middlewares/tracing/index.js +27 -14
- package/lib/middlewares/tracing/tags.js +43 -0
- package/lib/middlewares/validator/index.js +6 -6
- package/lib/registry/{action-endpoint.js → actionEndpoint.js} +0 -0
- package/lib/registry/collections/{action-collection.js → actionCollection.js} +2 -2
- package/lib/registry/collections/{endpoint-collection.js → endpointCollection.js} +19 -3
- package/lib/registry/collections/{event-collection.js → eventCollection.js} +15 -9
- package/lib/registry/collections/{node-collection.js → nodeCollection.js} +1 -1
- package/lib/registry/collections/{service-collection.js → serviceCollection.js} +2 -2
- package/lib/registry/{event-endpoint.js → eventEndpoint.js} +1 -1
- package/lib/registry/node.js +1 -1
- package/lib/registry/registry.js +19 -38
- package/lib/registry/service/service.js +2 -2
- package/lib/registry/{service-item.js → serviceItem.js} +1 -1
- package/lib/runtime/{init-action-invoker.js → initActionInvoker.js} +3 -3
- package/lib/runtime/initCache.js +19 -0
- package/lib/runtime/{init-context-factory.js → initContextFactory.js} +2 -2
- package/lib/runtime/{init-eventbus.js → initEventbus.js} +11 -10
- package/lib/runtime/{init-logger.js → initLogger.js} +0 -0
- package/lib/runtime/{init-metrics.js → initMetrics.js} +11 -10
- package/lib/runtime/{init-middleware-manager.js → initMiddlewareManager.js} +1 -1
- package/lib/runtime/{init-registry.js → initRegistry.js} +1 -1
- package/lib/runtime/{init-service-manager.js → initServiceManager.js} +0 -0
- package/lib/runtime/{init-tracing.js → initTracing.js} +2 -1
- package/lib/runtime/{init-transport.js → initTransport.js} +0 -0
- package/lib/runtime/{init-uuid-factory.js → initUuidFactory.js} +0 -0
- package/lib/runtime/{init-validator.js → initValidator.js} +1 -1
- package/lib/tracing/collectors/base.js +11 -19
- package/lib/tracing/collectors/event.js +2 -2
- package/lib/tracing/collectors/index.js +2 -2
- package/lib/tracing/span.js +8 -6
- package/lib/transport/InboundTransformStream.js +75 -0
- package/lib/transport/adapters/{adapter-base.js → adapteBase.js} +16 -1
- package/lib/transport/adapters/adapters.js +1 -1
- package/lib/transport/adapters/dummy/index.js +3 -3
- package/lib/transport/adapters/index.js +1 -1
- package/lib/transport/adapters/tcp/discovery/index.js +45 -31
- package/lib/transport/adapters/tcp/index.js +20 -13
- package/lib/transport/adapters/tcp/tcpReader.js +1 -0
- package/lib/transport/adapters/tcp/tcpWriteStream.js +1 -1
- package/lib/transport/adapters/tcp/tcpWriter.js +2 -2
- package/lib/transport/createMessage.js +11 -0
- package/lib/transport/createTransport.js +215 -172
- package/lib/transport/errorPayloadFactory.js +18 -0
- package/lib/transport/{message-handlers.js → messageHandlers.js} +92 -23
- package/lib/transport/messageTypes.js +23 -0
- package/lib/types.js +86 -75
- package/lib/utils/index.js +1 -1
- package/lib/utils/options.js +4 -2
- package/lib/utils/{restore-error.js → restoreError.js} +1 -1
- package/package.json +6 -12
- package/CHANGELOG.md +0 -1317
- package/lib/cache/index.js +0 -48
- package/lib/cache/memory.js +0 -91
- package/lib/middlewares/tracing/buildTags.js +0 -17
- package/lib/new-errors.js +0 -25
- package/lib/runtime/init-cache.js +0 -10
- package/lib/tracing/collectors/console.js +0 -34
- package/lib/tracing/index.js +0 -3
- package/lib/tracing/tracer.js +0 -64
- package/lib/transport/message-types.js +0 -59
- package/lib/transport/message.js +0 -16
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const { Transform } = require('stream')
|
|
2
|
+
|
|
3
|
+
const pushWithBackpressure = (stream, chunks, encoding, callback = null, $index = 0) => {
|
|
4
|
+
if (!(stream instanceof Transform)) {
|
|
5
|
+
throw new TypeError('Argument "stream" must be an instance of Duplex')
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
chunks = [].concat(chunks).filter(x => x !== undefined)
|
|
9
|
+
|
|
10
|
+
if (typeof encoding === 'function') {
|
|
11
|
+
callback = encoding
|
|
12
|
+
encoding = undefined
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if ($index >= chunks.length) {
|
|
16
|
+
if (typeof callback === 'function') {
|
|
17
|
+
callback()
|
|
18
|
+
}
|
|
19
|
+
return stream
|
|
20
|
+
} else if (!stream.push(chunks[$index], ...([encoding].filter(Boolean)))) {
|
|
21
|
+
stream.emit('backpressure', {
|
|
22
|
+
sender: stream.sender,
|
|
23
|
+
requestId: stream.requestId
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const pipedStreams = [].concat(
|
|
27
|
+
(stream._readableState || {}).pipes || stream
|
|
28
|
+
).filter(Boolean)
|
|
29
|
+
|
|
30
|
+
let listenerCalled = false
|
|
31
|
+
|
|
32
|
+
const drainListener = () => {
|
|
33
|
+
stream.emit('resume_backpressure', {
|
|
34
|
+
sender: stream.sender,
|
|
35
|
+
requestId: stream.requestId
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
if (listenerCalled) {
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
listenerCalled = true
|
|
43
|
+
|
|
44
|
+
for (const stream of pipedStreams) {
|
|
45
|
+
stream.removeListener('drain', drainListener)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
pushWithBackpressure(stream, chunks, encoding, callback, $index + 1)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
for (const stream of pipedStreams) {
|
|
52
|
+
stream.once('drain', drainListener)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return stream
|
|
56
|
+
}
|
|
57
|
+
return pushWithBackpressure(stream, chunks, encoding, callback, $index + 1)
|
|
58
|
+
}
|
|
59
|
+
class InboundTransformStream extends Transform {
|
|
60
|
+
constructor (sender, requestId, options) {
|
|
61
|
+
super(options)
|
|
62
|
+
this.sender = sender
|
|
63
|
+
this.requestId = requestId
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
_transform (chunk, encoding, callback) {
|
|
67
|
+
pushWithBackpressure(this, chunk, encoding, callback)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_flush (callback) {
|
|
71
|
+
return callback()
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = { InboundTransformStream }
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Author: Kevin Ries (kevin@fachw3rk.de)
|
|
3
3
|
* -----
|
|
4
|
-
* Copyright
|
|
4
|
+
* Copyright 2021 Fachwerk
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const EventEmitter = require('events').EventEmitter
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Object} AdapterBase
|
|
11
|
+
* @property {string} name Name
|
|
12
|
+
* @property {EventEmitter} bus Event bus.
|
|
13
|
+
* @property {function():Promise<any>} afterInit After init callback.
|
|
14
|
+
* @property {boolean} isConnected Is connected state.
|
|
15
|
+
* @property {number} interruptCounter Interruption counter.
|
|
16
|
+
* @property {number} repeatAttemptCounter Repeat attempt counter
|
|
17
|
+
* @property {function(Object, Object, Object):Promise<any>} init Repeat attempt counter
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Create a adapter base object.
|
|
22
|
+
* @returns {AdapterBase} Adapter base object
|
|
23
|
+
*/
|
|
9
24
|
const createTransportBase = () => {
|
|
10
25
|
let prefix = 'weave'
|
|
11
26
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Author: Kevin Ries (kevin@fachw3rk.de)
|
|
3
3
|
* -----
|
|
4
|
-
* Copyright
|
|
4
|
+
* Copyright 2021 Fachwerk
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const TransportBase = require('../
|
|
7
|
+
const TransportBase = require('../adapteBase')
|
|
8
8
|
const EventEmitter = require('eventemitter2').EventEmitter2
|
|
9
9
|
|
|
10
10
|
// create a global eventbus to pass messages between weave service brokers.
|
|
@@ -18,7 +18,7 @@ const DummyTransportAdapter = (adapterOptions) => {
|
|
|
18
18
|
|
|
19
19
|
return Object.assign(TransportBase(adapterOptions), {
|
|
20
20
|
name: 'Dummy',
|
|
21
|
-
connect (
|
|
21
|
+
connect () {
|
|
22
22
|
this.bus.emit('$adapter.connected', false)
|
|
23
23
|
this.log.info('Dummy transport client connected.')
|
|
24
24
|
return Promise.resolve()
|
|
@@ -12,7 +12,7 @@ const createDiscoveryService = (adapter, options) => {
|
|
|
12
12
|
const codec = Codec(options)
|
|
13
13
|
const bus = new EventEmitter()
|
|
14
14
|
const ips = getIpList(false)
|
|
15
|
-
const
|
|
15
|
+
const MESSAGE_TYPE_LENGTH = 1
|
|
16
16
|
|
|
17
17
|
let servers = []
|
|
18
18
|
let discoverTimer
|
|
@@ -20,32 +20,29 @@ const createDiscoveryService = (adapter, options) => {
|
|
|
20
20
|
const startServer = (host, port, multicastAddress) => {
|
|
21
21
|
return new Promise((resolve, reject) => {
|
|
22
22
|
try {
|
|
23
|
-
const socket = dgram.createSocket({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const messageType = Buffer.prototype.readUInt8.call(message, 0)
|
|
27
|
-
const payload = message.slice(MESSAGE_TYPE_LENGHT)
|
|
28
|
-
|
|
29
|
-
switch (messageType) {
|
|
30
|
-
case messageTypes.HELLO:
|
|
31
|
-
onMessage(payload, info)
|
|
32
|
-
break
|
|
33
|
-
default:
|
|
34
|
-
onUnknown(payload, info)
|
|
35
|
-
}
|
|
23
|
+
const socket = dgram.createSocket({
|
|
24
|
+
type: options.discovery.type,
|
|
25
|
+
reuseAddr: options.discovery.udpReuseAddress
|
|
36
26
|
})
|
|
37
27
|
|
|
38
|
-
socket.
|
|
28
|
+
socket.on('message', onMessage)
|
|
29
|
+
|
|
30
|
+
socket.bind({ port, exclusive: true }, () => {
|
|
39
31
|
try {
|
|
40
32
|
if (multicastAddress) {
|
|
41
33
|
socket.setMulticastInterface(host)
|
|
42
34
|
socket.addMembership(multicastAddress, host)
|
|
43
35
|
socket.setMulticastTTL(1)
|
|
44
|
-
socket
|
|
36
|
+
// Add destination to socket object
|
|
37
|
+
Object.defineProperty(socket, 'destinations', {
|
|
38
|
+
value: [multicastAddress]
|
|
39
|
+
})
|
|
45
40
|
adapter.log.info(`UDP Server is listening on ${host}:${port}. Membership: ${multicastAddress}`)
|
|
46
41
|
} else {
|
|
47
42
|
socket.setBroadcast(true)
|
|
48
|
-
socket
|
|
43
|
+
Object.defineProperty(socket, 'destinations', {
|
|
44
|
+
value: getBroadcastAddresses()
|
|
45
|
+
})
|
|
49
46
|
}
|
|
50
47
|
} catch (error) {
|
|
51
48
|
adapter.log.info(`UDP Multicast membership error: ${error.message}`)
|
|
@@ -62,20 +59,25 @@ const createDiscoveryService = (adapter, options) => {
|
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
const onMessage = (buffer, info) => {
|
|
65
|
-
const
|
|
66
|
-
|
|
62
|
+
const messageType = Buffer.prototype.readUInt8.call(buffer, 0)
|
|
63
|
+
const payload = buffer.slice(MESSAGE_TYPE_LENGTH)
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
switch (messageType) {
|
|
66
|
+
case messageTypes.HELLO:
|
|
67
|
+
const message = codec.decode(payload)
|
|
68
|
+
message.host = info.address
|
|
72
69
|
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
if (message.namespace === namespace) {
|
|
71
|
+
bus.emit('message', message)
|
|
72
|
+
}
|
|
73
|
+
break
|
|
74
|
+
default:
|
|
75
|
+
adapter.log.debug(`Received an unknown data package from host "${info.address}"`)
|
|
76
|
+
}
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
function sendMessage (payload) {
|
|
78
|
-
const header = Buffer.alloc(
|
|
80
|
+
const header = Buffer.alloc(MESSAGE_TYPE_LENGTH)
|
|
79
81
|
Buffer.prototype.writeUInt8.call(header, messageTypes.HELLO, 0)
|
|
80
82
|
|
|
81
83
|
const message = Buffer.concat([header, codec.encode(payload)])
|
|
@@ -101,7 +103,6 @@ const createDiscoveryService = (adapter, options) => {
|
|
|
101
103
|
|
|
102
104
|
function startDiscovering (port) {
|
|
103
105
|
discoverTimer = setInterval(() => sendDiscoveryPackage(port), 2000)
|
|
104
|
-
|
|
105
106
|
discoverTimer.unref()
|
|
106
107
|
}
|
|
107
108
|
|
|
@@ -115,14 +116,27 @@ const createDiscoveryService = (adapter, options) => {
|
|
|
115
116
|
|
|
116
117
|
return {
|
|
117
118
|
bus,
|
|
118
|
-
|
|
119
|
+
async start (port) {
|
|
119
120
|
if (!options.discovery.enabled) {
|
|
120
121
|
return Promise.resolve()
|
|
121
122
|
}
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
.
|
|
124
|
+
// UDP Multicast
|
|
125
|
+
if (options.discovery.udpMulticast) {
|
|
126
|
+
if (options.discovery.multicastAddress) {
|
|
127
|
+
await Promise.all(ips.map(ip => startServer(ip, options.discovery.port, options.discovery.multicastAddress)))
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// UDP Broadcast
|
|
132
|
+
if (options.discovery.udpBroadcast) {
|
|
133
|
+
await startServer(options.discovery.udpBindAddress, options.discovery.port, options.discovery.multicastAddress)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// send the first dis
|
|
137
|
+
const timeout = Math.floor(Math.random() * 500) + 500
|
|
138
|
+
setTimeout(() => sendDiscoveryPackage(port), timeout)
|
|
139
|
+
startDiscovering(port)
|
|
126
140
|
},
|
|
127
141
|
close () {
|
|
128
142
|
stopDiscovery()
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
const { defaultsDeep } = require('@weave-js/utils')
|
|
3
|
-
const TransportBase = require('../
|
|
3
|
+
const TransportBase = require('../adapteBase')
|
|
4
4
|
const Swim = require('./discovery/index')
|
|
5
|
-
const MessageTypes = require('../../
|
|
5
|
+
const MessageTypes = require('../../messageTypes')
|
|
6
6
|
const TCPReader = require('./tcpReader')
|
|
7
7
|
const TCPWriter = require('./tcpWriter')
|
|
8
|
+
const { createMessage } = require('../../createMessage')
|
|
9
|
+
|
|
8
10
|
// const TCPMessageTypeHelper = require('./tcp-messagetypes')
|
|
9
11
|
|
|
10
12
|
const defaultOptions = {
|
|
@@ -12,6 +14,7 @@ const defaultOptions = {
|
|
|
12
14
|
discovery: {
|
|
13
15
|
enabled: true,
|
|
14
16
|
type: 'udp4',
|
|
17
|
+
udpMulticast: true,
|
|
15
18
|
multicastAddress: '239.0.0.0',
|
|
16
19
|
port: 54355,
|
|
17
20
|
udpReuseAddress: true
|
|
@@ -59,7 +62,11 @@ module.exports = function SwimTransport (adapterOptions) {
|
|
|
59
62
|
MessageTypes.MESSAGE_RESPONSE,
|
|
60
63
|
MessageTypes.MESSAGE_GOSSIP_HELLO,
|
|
61
64
|
MessageTypes.MESSAGE_GOSSIP_REQUEST,
|
|
62
|
-
MessageTypes.MESSAGE_GOSSIP_RESPONSE
|
|
65
|
+
MessageTypes.MESSAGE_GOSSIP_RESPONSE,
|
|
66
|
+
MessageTypes.MESSAGE_RESPONSE_STREAM_BACKPRESSURE,
|
|
67
|
+
MessageTypes.MESSAGE_RESPONSE_STREAM_RESUME,
|
|
68
|
+
MessageTypes.MESSAGE_REQUEST_STREAM_BACKPRESSURE,
|
|
69
|
+
MessageTypes.MESSAGE_REQUEST_STREAM_RESUME
|
|
63
70
|
].includes(message.type)) {
|
|
64
71
|
if (message.type === MessageTypes.MESSAGE_DISCONNECT) {
|
|
65
72
|
// send a disconnect message to all connected nodes
|
|
@@ -81,7 +88,7 @@ module.exports = function SwimTransport (adapterOptions) {
|
|
|
81
88
|
|
|
82
89
|
const localNode = self.broker.registry.nodeCollection.localNode
|
|
83
90
|
|
|
84
|
-
const message =
|
|
91
|
+
const message = createMessage(MessageTypes.MESSAGE_GOSSIP_HELLO, nodeId, {
|
|
85
92
|
host: localNode.IPList[0],
|
|
86
93
|
port: localNode.port
|
|
87
94
|
})
|
|
@@ -165,7 +172,7 @@ module.exports = function SwimTransport (adapterOptions) {
|
|
|
165
172
|
}
|
|
166
173
|
})
|
|
167
174
|
|
|
168
|
-
self.swim.
|
|
175
|
+
self.swim.start(port)
|
|
169
176
|
}
|
|
170
177
|
|
|
171
178
|
function startTCPServer () {
|
|
@@ -174,19 +181,19 @@ module.exports = function SwimTransport (adapterOptions) {
|
|
|
174
181
|
|
|
175
182
|
tcpReader.on('message', onMessage)
|
|
176
183
|
|
|
177
|
-
tcpWriter.on('error', (error,
|
|
184
|
+
tcpWriter.on('error', (error, nodeId) => {
|
|
178
185
|
self.log.debug('TCP client error on ', error)
|
|
179
|
-
self.broker.registry.nodeDisconnected(
|
|
186
|
+
self.broker.registry.nodeDisconnected(nodeId, false)
|
|
180
187
|
})
|
|
181
188
|
|
|
182
|
-
tcpWriter.on('end',
|
|
189
|
+
tcpWriter.on('end', nodeId => {
|
|
183
190
|
self.log.debug('TCP connection ended with')
|
|
184
|
-
self.broker.registry.nodeDisconnected(
|
|
191
|
+
self.broker.registry.nodeDisconnected(nodeId, false)
|
|
185
192
|
})
|
|
186
193
|
|
|
187
|
-
// tcpWriter.on('error', (_,
|
|
194
|
+
// tcpWriter.on('error', (_, nodeId) => {
|
|
188
195
|
// self.log.debug('TCP server error on ')
|
|
189
|
-
// // this.nodes.disconnected(
|
|
196
|
+
// // this.nodes.disconnected(nodeId, false)
|
|
190
197
|
// })
|
|
191
198
|
|
|
192
199
|
return tcpReader.listen()
|
|
@@ -250,7 +257,7 @@ module.exports = function SwimTransport (adapterOptions) {
|
|
|
250
257
|
|
|
251
258
|
const destinationNode = nodes[Math.floor(Math.random() * nodes.length)]
|
|
252
259
|
if (destinationNode) {
|
|
253
|
-
const message =
|
|
260
|
+
const message = createMessage(MessageTypes.MESSAGE_GOSSIP_REQUEST, destinationNode.id, payload)
|
|
254
261
|
|
|
255
262
|
self.send(message).catch(() => {
|
|
256
263
|
self.log.debug(`Unable to send gossip response to ${destinationNode.id}`)
|
|
@@ -357,7 +364,7 @@ module.exports = function SwimTransport (adapterOptions) {
|
|
|
357
364
|
|
|
358
365
|
if (response.online || response.offline) {
|
|
359
366
|
const destinationNode = self.broker.registry.nodeCollection.get(payload.sender)
|
|
360
|
-
const message =
|
|
367
|
+
const message = createMessage(MessageTypes.MESSAGE_GOSSIP_RESPONSE, destinationNode.id, response)
|
|
361
368
|
self.send(message).catch(() => {})
|
|
362
369
|
}
|
|
363
370
|
} catch (error) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
const { Writable } = require('stream')
|
|
3
|
-
const MessageTypes = require('../../
|
|
3
|
+
const MessageTypes = require('../../messageTypes')
|
|
4
4
|
const TCPMessageTypeHelper = require('./tcp-messagetypes')
|
|
5
5
|
|
|
6
6
|
module.exports = class TCPWriteStream extends Writable {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const net = require('net')
|
|
2
2
|
const { EventEmitter } = require('events')
|
|
3
|
-
const MessageTypes = require('../../
|
|
3
|
+
const MessageTypes = require('../../messageTypes')
|
|
4
4
|
const TCPMessageTypeHelper = require('./tcp-messagetypes')
|
|
5
5
|
|
|
6
|
-
module.exports = (adapter
|
|
6
|
+
module.exports = (adapter) => {
|
|
7
7
|
const self = Object.assign({}, EventEmitter.prototype)
|
|
8
8
|
const sockets = new Map()
|
|
9
9
|
const messageTypeHelper = TCPMessageTypeHelper(MessageTypes)
|