comq 0.5.1-dev.0 → 0.5.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.
@@ -4,7 +4,14 @@ updates:
4
4
  directory: "/"
5
5
  schedule:
6
6
  interval: "weekly"
7
+ target-branch: "dev"
8
+ labels:
9
+ - "dependency"
10
+ - "actions"
7
11
  - package-ecosystem: "npm"
8
12
  directory: "/"
9
13
  schedule:
10
14
  interval: "daily"
15
+ target-branch: "dev"
16
+ labels:
17
+ - "dependency"
@@ -0,0 +1,76 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ "main" ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ "main" ]
20
+ schedule:
21
+ - cron: '15 8 * * 3'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'javascript' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Use only 'java' to analyze code written in Java, Kotlin or both
38
+ # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
39
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
40
+
41
+ steps:
42
+ - name: Checkout repository
43
+ uses: actions/checkout@v3
44
+
45
+ # Initializes the CodeQL tools for scanning.
46
+ - name: Initialize CodeQL
47
+ uses: github/codeql-action/init@v2
48
+ with:
49
+ languages: ${{ matrix.language }}
50
+ # If you wish to specify custom queries, you can do so here or in a config file.
51
+ # By default, queries listed here will override any specified in a config file.
52
+ # Prefix the list here with "+" to use these queries and those in the config file.
53
+
54
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
55
+ # queries: security-extended,security-and-quality
56
+
57
+
58
+ # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
59
+ # If this step fails, then you should remove it and run the build manually (see below)
60
+ - name: Autobuild
61
+ uses: github/codeql-action/autobuild@v2
62
+
63
+ # ℹ️ Command-line programs to run using the OS shell.
64
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
65
+
66
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
67
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
68
+
69
+ # - run: |
70
+ # echo "Run, Build Application using script"
71
+ # ./location_of_script_within_repo/buildscript.sh
72
+
73
+ - name: Perform CodeQL Analysis
74
+ uses: github/codeql-action/analyze@v2
75
+ with:
76
+ category: "/language:${{matrix.language}}"
@@ -115,10 +115,14 @@ Then('all events have been received',
115
115
  async function consume (group, exchange) {
116
116
  this.consumed ??= {}
117
117
 
118
- return this.io.consume(exchange, group, async (payload) => {
118
+ const consumer = async (payload) => {
119
119
  this.consumed[group] = payload
120
120
  this.eventsConsumedCount++
121
- })
121
+ }
122
+
123
+ return group === undefined
124
+ ? this.io.consume(exchange, consumer)
125
+ : this.io.consume(exchange, group, consumer)
122
126
  }
123
127
 
124
128
  /**
package/lerna.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "useWorkspaces": true,
3
- "version": "0.5.1-dev.0",
3
+ "version": "0.5.1",
4
4
  "conventionalCommits": true
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comq",
3
- "version": "0.5.1-dev.0",
3
+ "version": "0.5.1",
4
4
  "description": "ComQ",
5
5
  "author": {
6
6
  "name": "Artem Gurtovoi",
package/readme.md CHANGED
@@ -124,8 +124,8 @@ Event message is delivered to a single Consumer within *each group*.
124
124
  > Typically, the value of `group` refers to the name of a microservice running in multiple
125
125
  > instances.
126
126
 
127
- If the `group` is `undefined` or omitted, a unique value is generated and the queue is declared as
128
- exclusive.
127
+ If the `group` is `undefined` or omitted, a queue for the Consumer is asserted as exclusive with
128
+ auto-generated name.
129
129
 
130
130
  ### Example
131
131
 
package/source/io.js CHANGED
@@ -83,7 +83,12 @@ class IO {
83
83
 
84
84
  consume = lazy(this, this.#createEventChannel,
85
85
  async (exchange, group, callback) => {
86
- const exclusive = group === undefined || callback === undefined // 2 arguments passed
86
+ if (callback === undefined) { // 2 arguments passed
87
+ callback = group
88
+ group = undefined
89
+ }
90
+
91
+ const exclusive = group === undefined
87
92
  const queue = exclusive ? undefined : io.concat(exchange, group)
88
93
  const consumer = this.#getEventConsumer(callback)
89
94
 
@@ -84,6 +84,18 @@ describe.each(['omitted', 'undefined'])('exclusive consumption (group is %s)', (
84
84
  expect(events).toBeDefined()
85
85
  expect(events.subscribe).toHaveBeenCalledWith(exchange, undefined, expect.any(Function))
86
86
  })
87
+
88
+ it('should pass messages to the consumer', async () => {
89
+ const emit = events.subscribe.mock.calls[0][2]
90
+ const content = generate()
91
+ const contentType = 'text/plain'
92
+ const properties = { contentType }
93
+ const message = { content, properties }
94
+
95
+ await emit(message)
96
+
97
+ expect(consumer).toHaveBeenCalledWith(message.content)
98
+ })
87
99
  })
88
100
 
89
101
  /**