-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9655758
Showing
27 changed files
with
7,128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"env": { | ||
"es2020": true, | ||
"jest/globals": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"standard" | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": 2020 | ||
}, | ||
"plugins": [ | ||
"jest" | ||
], | ||
"rules": { | ||
"indent": [ | ||
"warn", | ||
4 | ||
], | ||
"linebreak-style": [ | ||
"warn", | ||
"unix" | ||
], | ||
"quotes": [ | ||
"error", | ||
"single" | ||
], | ||
"semi": [ | ||
"warn", | ||
"always" | ||
], | ||
"prefer-template": 2, | ||
"no-useless-concat": 2, | ||
"no-unused-vars": 2, | ||
"no-undef": 2, | ||
"no-var": 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# next.js build output | ||
.next | ||
|
||
# Mac Finder thumbnail store | ||
.DS_Store | ||
|
||
temp | ||
|
||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
language: node_js | ||
node_js: | ||
- 14 | ||
- 15 | ||
install: | ||
- yarn | ||
services: | ||
- redis-server | ||
script: | ||
- yarn lint | ||
- yarn coverage | ||
notifications: | ||
email: | ||
on_success: never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
##### Description 🖋 | ||
<!--- Briefly describe your changes --> | ||
|
||
##### Types of changes 🌈 | ||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> | ||
- [ ] Bug fix (non-breaking change which fixes an issue) | ||
- [ ] New feature (non-breaking change which adds functionality) | ||
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# BlubBlub Node Queue | ||
|
||
Repository contains the queue service with endpoints to manage the queue. | ||
|
||
## Installation | ||
|
||
This project only contains NPM dependencies, to install them use the following command. | ||
|
||
```shell script | ||
yarn install | ||
``` | ||
|
||
## Testing & Linting | ||
|
||
### Linting | ||
|
||
Project have predefined ESLint configuration file with style and static code analysis setup. | ||
|
||
```shell script | ||
yarn lint | ||
``` | ||
|
||
### Testing | ||
|
||
To run the tests simpy use the command below. | ||
|
||
```shell script | ||
yarn test | ||
``` | ||
|
||
Or in case if you want to also generate coverage report. | ||
|
||
```shell script | ||
yarn coverage | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const consumer = require('./lib/consumer'); | ||
const endpoints = require('./lib/endpoints'); | ||
const service = require('./lib/service'); | ||
|
||
module.exports = { | ||
Consumer: consumer, | ||
Router: endpoints, | ||
Service: service | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const consumer = require('../consumer'); | ||
const service = require('../service'); | ||
|
||
const utils = require('../../test/utils'); | ||
|
||
jest.mock('ioredis'); | ||
|
||
beforeEach(async () => { | ||
await utils.setupQueues([{ | ||
name: 'queue' | ||
}, { | ||
name: 'default', | ||
defaultJobOptions: { | ||
test: 'test' | ||
} | ||
}]); | ||
}); | ||
|
||
afterEach(async () => { | ||
await utils.cleanUpAndDisconnect(service); | ||
}); | ||
|
||
describe('Queue Consumer', () => { | ||
test('Process defaults', async () => { | ||
consumer(service, {}); | ||
|
||
expect(await service.getQueue('default').getWorkers()).toHaveLength(1); | ||
}); | ||
|
||
test('Concurrency', async () => { | ||
await utils.setupQueues([{ | ||
name: 'multiworker', | ||
metadata: { | ||
processNumber: 3 | ||
} | ||
}]); | ||
|
||
jest.spyOn(service.getQueue('multiworker'), 'process'); | ||
|
||
consumer(service, {}); | ||
|
||
expect(service.getQueue('multiworker').process).toBeCalledTimes(1); | ||
expect(service.getQueue('multiworker').process).toBeCalledWith('*', 3, expect.any(Function)); | ||
}); | ||
}); |
Oops, something went wrong.