comq 0.8.0-dev.0 → 0.8.0-dev.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/features/steps/.types/context.d.ts +1 -1
- package/features/steps/connection.js +2 -2
- package/features/steps/context.js +3 -3
- package/lerna.json +1 -1
- package/package.json +1 -1
- package/readme.md +3 -3
- package/source/connect.js +2 -2
- package/source/connection.js +11 -3
- package/source/index.js +2 -2
- package/test/{join.test.js → assert.test.js} +4 -4
- package/test/connection.test.js +6 -0
- package/types/index.d.ts +1 -1
|
@@ -25,7 +25,7 @@ declare namespace comq.features {
|
|
|
25
25
|
publishing: any
|
|
26
26
|
|
|
27
27
|
connect(user?: string, password?: string): Promise<void>
|
|
28
|
-
|
|
28
|
+
assert(user?: string, password?: string): Promise<void>
|
|
29
29
|
disconnect(): Promise<void>
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -31,7 +31,7 @@ Given('an active singleton connection',
|
|
|
31
31
|
* @this {comq.features.Context}
|
|
32
32
|
*/
|
|
33
33
|
async function () {
|
|
34
|
-
this.connecting = this.
|
|
34
|
+
this.connecting = this.assert()
|
|
35
35
|
|
|
36
36
|
await this.connecting
|
|
37
37
|
})
|
|
@@ -42,7 +42,7 @@ Given('an active sharded singleton connection',
|
|
|
42
42
|
*/
|
|
43
43
|
async function () {
|
|
44
44
|
this.sharded = true
|
|
45
|
-
this.connecting = this.
|
|
45
|
+
this.connecting = this.assert()
|
|
46
46
|
|
|
47
47
|
await this.connecting
|
|
48
48
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { World } = require('@cucumber/cucumber')
|
|
4
|
-
const { connect,
|
|
4
|
+
const { connect, assert } = require('../../')
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @implements {comq.features.Context}
|
|
@@ -29,10 +29,10 @@ class Context extends World {
|
|
|
29
29
|
await this.#connect(urls)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
async
|
|
32
|
+
async assert (user, password) {
|
|
33
33
|
const urls = this.#urls(user, password)
|
|
34
34
|
|
|
35
|
-
await this.#connect(urls,
|
|
35
|
+
await this.#connect(urls, assert)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
async disconnect () {
|
package/lerna.json
CHANGED
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -223,16 +223,16 @@ await io.close()
|
|
|
223
223
|
|
|
224
224
|
## Singleton connection
|
|
225
225
|
|
|
226
|
-
`async
|
|
226
|
+
`async assert(url: string): IO`
|
|
227
227
|
|
|
228
228
|
Similar to [`connect`](#connect), but it utilizes shared underlying connections.
|
|
229
229
|
|
|
230
|
-
The connection is established once per unique `url` among instances of `IO` created with `
|
|
230
|
+
The connection is established once per unique `url` among instances of `IO` created with `assert`,
|
|
231
231
|
and it will be closed when the last instance of `IO` using that connection is [disconnected](#disconnection).
|
|
232
232
|
|
|
233
233
|
[Sharded connections](#sharded-connection) are also supported.
|
|
234
234
|
|
|
235
|
-
`async
|
|
235
|
+
`async assert(...shards: string[]): IO`
|
|
236
236
|
|
|
237
237
|
## Topology
|
|
238
238
|
|
package/source/connect.js
CHANGED
|
@@ -11,7 +11,7 @@ const connect = async (...urls) => {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/** @type {comq.connect} */
|
|
14
|
-
const
|
|
14
|
+
const assert = async (...urls) => {
|
|
15
15
|
return create(urls, connectionConstructor(SingletonConnection))
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -50,4 +50,4 @@ const shardedConnection = (urls, ConnectionClass) => {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
exports.connect = connect
|
|
53
|
-
exports.
|
|
53
|
+
exports.assert = assert
|
package/source/connection.js
CHANGED
|
@@ -26,7 +26,7 @@ class Connection {
|
|
|
26
26
|
/** @type {boolean} */
|
|
27
27
|
#running = false
|
|
28
28
|
|
|
29
|
-
#diagnostics =
|
|
29
|
+
#diagnostics = createEmitter()
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* @param {string} url
|
|
@@ -114,11 +114,19 @@ class Connection {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
function createEmitter () {
|
|
118
|
+
const emitter = new EventEmitter()
|
|
119
|
+
|
|
120
|
+
emitter.setMaxListeners(10000)
|
|
121
|
+
|
|
122
|
+
return emitter
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function noop () {}
|
|
126
|
+
|
|
117
127
|
/** @type {toa.generic.retry.Options} */
|
|
118
128
|
const RETRY = {
|
|
119
129
|
retries: Infinity
|
|
120
130
|
}
|
|
121
131
|
|
|
122
|
-
function noop () {}
|
|
123
|
-
|
|
124
132
|
exports.Connection = Connection
|
package/source/index.js
CHANGED
|
@@ -16,7 +16,7 @@ const {
|
|
|
16
16
|
const shards = /** @type {{ Connection: jest.MockedClass<comq.Connection>}} */
|
|
17
17
|
require('../source/shards')
|
|
18
18
|
|
|
19
|
-
const {
|
|
19
|
+
const { assert } = require('../')
|
|
20
20
|
|
|
21
21
|
const url = generate()
|
|
22
22
|
|
|
@@ -26,11 +26,11 @@ let io
|
|
|
26
26
|
beforeEach(async () => {
|
|
27
27
|
jest.clearAllMocks()
|
|
28
28
|
|
|
29
|
-
io = await
|
|
29
|
+
io = await assert(url)
|
|
30
30
|
})
|
|
31
31
|
|
|
32
32
|
it('should be', async () => {
|
|
33
|
-
expect(
|
|
33
|
+
expect(assert).toBeInstanceOf(Function)
|
|
34
34
|
})
|
|
35
35
|
|
|
36
36
|
it('should return instance of IO', async () => {
|
|
@@ -48,7 +48,7 @@ it('should create sharded connection', async () => {
|
|
|
48
48
|
|
|
49
49
|
const urls = [generate(), generate()]
|
|
50
50
|
|
|
51
|
-
io = await
|
|
51
|
+
io = await assert(...urls)
|
|
52
52
|
|
|
53
53
|
for (const url of urls) expect(SingletonConnection).toHaveBeenCalledWith(url)
|
|
54
54
|
|
package/test/connection.test.js
CHANGED
package/types/index.d.ts
CHANGED