comq 0.5.0 → 0.5.1-dev.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.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: 'fix: '
5
+ labels: Bug
6
+ assignees: temich
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+
16
+ **Expected behavior**
17
+ A clear and concise description of what you expected to happen.
18
+
19
+ **Additional context**
20
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ - package-ecosystem: "npm"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "daily"
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ tema.gurtovoy@gmail.com.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Toa
3
+ Copyright (c) 2023-present Artem Gurtovoi
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -2,6 +2,8 @@
2
2
 
3
3
  To run examples please start RabbitMQ server with `docker compose up -d` in the package root.
4
4
 
5
+ > Try to run example first.
6
+
5
7
  ## RPC
6
8
 
7
9
  Run in two terminals:
package/lerna.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "useWorkspaces": true,
3
- "version": "0.5.0",
3
+ "version": "0.5.1-dev.0",
4
4
  "conventionalCommits": true
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comq",
3
- "version": "0.5.0",
3
+ "version": "0.5.1-dev.0",
4
4
  "description": "ComQ",
5
5
  "author": {
6
6
  "name": "Artem Gurtovoi",
@@ -14,6 +14,10 @@
14
14
  "bugs": {
15
15
  "url": "https://github.com/toa-io/comq/issues"
16
16
  },
17
+ "keywords": [
18
+ "AMQP",
19
+ "RabbitMQ"
20
+ ],
17
21
  "engines": {
18
22
  "node": ">= 12.0.0"
19
23
  },
@@ -23,13 +27,13 @@
23
27
  "main": "source/index.js",
24
28
  "types": "types/index.d.ts",
25
29
  "devDependencies": {
26
- "@cucumber/cucumber": "9.0.0",
30
+ "@cucumber/cucumber": "9.0.1",
27
31
  "@toa.io/command": "0.3.0",
28
32
  "@toa.io/mock": "0.3.0",
29
33
  "@toa.io/tomato": "0.4.0-dev.2",
30
34
  "@toa.io/yaml": "0.4.0-dev.2",
31
35
  "@types/amqplib": "0.10.1",
32
- "@types/jest": "29.4.2",
36
+ "@types/jest": "29.5.0",
33
37
  "husky": "8.0.3",
34
38
  "jest": "29.5.0",
35
39
  "randomstring": "1.2.3",
package/source/channel.js CHANGED
@@ -104,7 +104,7 @@ class Channel {
104
104
  await this.#publish(exchange, DEFAULT, buffer, options)
105
105
  }))
106
106
 
107
- async throw (queue, buffer, options) {
107
+ async fire (queue, buffer, options) {
108
108
  try {
109
109
  await this.#publish(DEFAULT, queue, buffer, options)
110
110
  } catch (exception) {
package/source/io.js CHANGED
@@ -184,7 +184,7 @@ class IO {
184
184
  const buffer = contentType === OCTETS ? reply : encode(reply, contentType)
185
185
  const properties = { contentType, correlationId }
186
186
 
187
- await this.#replies.throw(message.properties.replyTo, buffer, properties)
187
+ await this.#replies.fire(message.properties.replyTo, buffer, properties)
188
188
  })
189
189
 
190
190
  /**
@@ -63,8 +63,8 @@ class Channel {
63
63
  await this.#one((channel) => channel.publish(exchange, buffer, options))
64
64
  }
65
65
 
66
- async throw (queue, buffer, options) {
67
- await this.#one((channel) => channel.throw(queue, buffer, options))
66
+ async fire (queue, buffer, options) {
67
+ await this.#one((channel) => channel.fire(queue, buffer, options))
68
68
  }
69
69
 
70
70
  async seal () {
@@ -283,7 +283,7 @@ describe('send', () => {
283
283
  })
284
284
  })
285
285
 
286
- describe('throw', () => {
286
+ describe('fire', () => {
287
287
  const queue = generate()
288
288
  const buffer = randomBytes(10)
289
289
  const options = { contentType: 'application/octet-stream' }
@@ -294,11 +294,11 @@ describe('throw', () => {
294
294
  })
295
295
 
296
296
  it('should be', async () => {
297
- expect(channel.throw).toBeDefined()
297
+ expect(channel.fire).toBeDefined()
298
298
  })
299
299
 
300
300
  it('should publish a message', async () => {
301
- await channel.throw(queue, buffer, options)
301
+ await channel.fire(queue, buffer, options)
302
302
 
303
303
  const call = chan.publish.mock.calls[0]
304
304
 
@@ -311,7 +311,7 @@ describe('throw', () => {
311
311
  it('should ignore exceptions', async () => {
312
312
  chan.publish.mockImplementation(() => { throw new Error() })
313
313
 
314
- await expect(channel.throw(queue, buffer, options)).resolves.not.toThrow()
314
+ await expect(channel.fire(queue, buffer, options)).resolves.not.toThrow()
315
315
  })
316
316
 
317
317
  it('should wait for unpause', async () => {
@@ -342,7 +342,7 @@ describe('throw', () => {
342
342
  chan.emit('drain')
343
343
  })
344
344
 
345
- await channel.throw(queue, buffer, options)
345
+ await channel.fire(queue, buffer, options)
346
346
 
347
347
  expect(chan.publish).toHaveBeenCalledTimes(3)
348
348
  })
@@ -900,7 +900,7 @@ describe('transient', () => {
900
900
  it('should not ignore exceptions on `throw()`', async () => {
901
901
  chan.publish.mockImplementation(() => { throw new Error('Channel closed') })
902
902
 
903
- await expect(channel.throw(queue, buffer)).rejects.toThrow()
903
+ await expect(channel.fire(queue, buffer)).rejects.toThrow()
904
904
  })
905
905
 
906
906
  it('should expose index', async () => {
@@ -7,7 +7,7 @@ const channel = /** @type {jest.MockedFunction<(sharded?: boolean, index?: numbe
7
7
  consume: jest.fn(async () => undefined),
8
8
  deliver: jest.fn(async () => undefined),
9
9
  send: jest.fn(async () => undefined),
10
- throw: jest.fn(async () => undefined),
10
+ fire: jest.fn(async () => undefined),
11
11
  subscribe: jest.fn(async () => undefined),
12
12
  publish: jest.fn(async () => undefined),
13
13
  diagnose: jest.fn(async () => undefined),
@@ -91,7 +91,7 @@ describe('reply', () => {
91
91
  beforeEach(async () => {
92
92
  })
93
93
 
94
- it('should `throw` reply', async () => {
94
+ it('should `fire` reply', async () => {
95
95
  await io.reply(queue, produce)
96
96
 
97
97
  requests = await findChannel('request')
@@ -107,7 +107,7 @@ describe('reply', () => {
107
107
  const reply = await produce.mock.results[0].value
108
108
  const buffer = encode(reply, properties.contentType)
109
109
 
110
- expect(replies.throw).toHaveBeenCalledWith(properties.replyTo, buffer, expect.anything())
110
+ expect(replies.fire).toHaveBeenCalledWith(properties.replyTo, buffer, expect.anything())
111
111
  })
112
112
 
113
113
  it('should throw if producer returned undefined', async () => {
@@ -177,7 +177,7 @@ describe('encoding', () => {
177
177
  contentType: properties.contentType
178
178
  }
179
179
 
180
- expect(replies.throw).toHaveBeenCalledWith(properties.replyTo, reply, props)
180
+ expect(replies.fire).toHaveBeenCalledWith(properties.replyTo, reply, props)
181
181
  })
182
182
 
183
183
  it('should set octet-stream for Buffer reply', async () => {
@@ -198,7 +198,7 @@ describe('encoding', () => {
198
198
 
199
199
  await producer(message)
200
200
 
201
- expect(replies.throw)
201
+ expect(replies.fire)
202
202
  .toHaveBeenCalledWith(
203
203
  expect.any(String),
204
204
  buffer,
@@ -140,7 +140,7 @@ describe.each(['consume', 'subscribe'])('%s', (method) => {
140
140
  })
141
141
  })
142
142
 
143
- describe.each(/** @type {string[]} */['send', 'publish', 'throw'])('%s', (method) => {
143
+ describe.each(/** @type {string[]} */['send', 'publish', 'fire'])('%s', (method) => {
144
144
  const label = generate()
145
145
  const buffer = randomBytes(8)
146
146
  const options = { contentType: generate() }
@@ -23,7 +23,7 @@ declare namespace comq {
23
23
 
24
24
  publish(exchange: string, buffer: Buffer, options?: Options.Publish): Promise<void>
25
25
 
26
- throw(queue: string, buffer: Buffer, options?: Options.Publish): Promise<void>
26
+ fire(queue: string, buffer: Buffer, options?: Options.Publish): Promise<void>
27
27
 
28
28
  seal(): Promise<void>
29
29
 
@@ -1,15 +0,0 @@
1
- - name: "Bug"
2
- description: "Something isn't working"
3
- color: "d73a4a"
4
- - name: "Critical"
5
- description: "Immediate action required"
6
- color: "ffff00"
7
- - name: "Docs"
8
- description: "Documentation improvements"
9
- color: "0075ca"
10
- - name: "Feature"
11
- description: "Feature request"
12
- color: "73E25B"
13
- - name: "Improvement"
14
- description: "Make something better"
15
- color: "6A1877"
@@ -1,18 +0,0 @@
1
- name: Labels
2
-
3
- on:
4
- push:
5
- branches:
6
- - 'dev'
7
- paths:
8
- - '.github/labels.yml'
9
- - '.github/workflows/labels.yml'
10
-
11
- jobs:
12
- labeler:
13
- runs-on: ubuntu-latest
14
- steps:
15
- - name: Checkout
16
- uses: actions/checkout@v3
17
- - name: Run Labeler
18
- uses: crazy-max/ghaction-github-labeler@v4