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.
@@ -25,7 +25,7 @@ declare namespace comq.features {
25
25
  publishing: any
26
26
 
27
27
  connect(user?: string, password?: string): Promise<void>
28
- join(user?: string, password?: string): Promise<void>
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.join()
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.join()
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, join } = require('../../')
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 join (user, password) {
32
+ async assert (user, password) {
33
33
  const urls = this.#urls(user, password)
34
34
 
35
- await this.#connect(urls, join)
35
+ await this.#connect(urls, assert)
36
36
  }
37
37
 
38
38
  async disconnect () {
package/lerna.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "useWorkspaces": true,
3
- "version": "0.8.0-dev.0",
3
+ "version": "0.8.0-dev.1",
4
4
  "conventionalCommits": true
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comq",
3
- "version": "0.8.0-dev.0",
3
+ "version": "0.8.0-dev.1",
4
4
  "description": "ComQ",
5
5
  "author": {
6
6
  "name": "Artem Gurtovoi",
package/readme.md CHANGED
@@ -223,16 +223,16 @@ await io.close()
223
223
 
224
224
  ## Singleton connection
225
225
 
226
- `async join(url: string): IO`
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 `join`,
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 join(...shards: string[]): IO`
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 join = async (...urls) => {
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.join = join
53
+ exports.assert = assert
@@ -26,7 +26,7 @@ class Connection {
26
26
  /** @type {boolean} */
27
27
  #running = false
28
28
 
29
- #diagnostics = new EventEmitter()
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
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const { connect, join } = require('./connect')
3
+ const { connect, assert } = require('./connect')
4
4
 
5
5
  exports.connect = connect
6
- exports.join = join
6
+ exports.assert = assert
@@ -16,7 +16,7 @@ const {
16
16
  const shards = /** @type {{ Connection: jest.MockedClass<comq.Connection>}} */
17
17
  require('../source/shards')
18
18
 
19
- const { join } = require('../')
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 join(url)
29
+ io = await assert(url)
30
30
  })
31
31
 
32
32
  it('should be', async () => {
33
- expect(join).toBeInstanceOf(Function)
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 join(...urls)
51
+ io = await assert(...urls)
52
52
 
53
53
  for (const url of urls) expect(SingletonConnection).toHaveBeenCalledWith(url)
54
54
 
@@ -253,4 +253,10 @@ describe('diagnostics', () => {
253
253
 
254
254
  expect(captured).toStrictEqual(error)
255
255
  })
256
+
257
+ it('should handle max listeners', async () => {
258
+ for (let i = 0; i < 100; i++) {
259
+ connection.diagnose('close', () => undefined)
260
+ }
261
+ })
256
262
  })
package/types/index.d.ts CHANGED
@@ -3,4 +3,4 @@ import { connect } from './connection'
3
3
  export type { IO, consumer, producer } from './io'
4
4
 
5
5
  export const connect: connect
6
- export const join: connect
6
+ export const assert: connect