Skip to content

Commit

Permalink
chore: add scafolding
Browse files Browse the repository at this point in the history
  • Loading branch information
manast committed Dec 28, 2018
1 parent 43e5efc commit b0b2863
Show file tree
Hide file tree
Showing 7 changed files with 5,396 additions and 59 deletions.
70 changes: 13 additions & 57 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,61 +1,17 @@
# Logs
logs
*.log
.DS_Store
node_modules
/dist

# Log files
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
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
language: node_js

sudo: false

# test on node.js versions
node_js:
- '10'
- '8'
- '6'

services:
- redis-server

script:
- npm run prettier -- --list-different
- npm run test

after_script:
- npm run coveralls

jobs:
include:
# Define the release stage that runs semantic-release
- stage: release
node_js: lts/*
# Advanced: optionally overwrite your default `script` step to skip the tests
# script: skip
deploy:
provider: script
skip_cleanup: true
script:
- npx semantic-release
77 changes: 75 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,75 @@
# bull
Bull - Premium Message Queue for NodeJS base on Redis
# Bull

```js
//
// A worker could just consume 1 redis connection (blocking)
// if it ignore delayed jobs. We can have a special class:
// DelayJobManager (just moves delay jobs to the queue when necessary)
//
const worker = new Worker('name', {
redis: {},
concurrency: number,
limiter: RateLimiterOpts,
skipDelayCheck: boolean,
visibilityWindow: seconds,
}, 'myprocessor.js');

// What about external processors
class MyWorker extend Worker {
async execute(jobName, jobData){
}
}

worker.on('completed', (job: Job) => {
console.log(job)
});
```

```js
const queue = new Queue("name", {
redis: RedisOpts
});

// FIFO
queue.append("jobName", data, opts: JobOpts);

// LIFO
queue.prepend("jobName", data, opts: JobOpts);

queue.on("completed", jobId => {});

queue.on("failed", (jobId, err) => {});

queue.on("delayed", (jobId, delay), => {});

// Listen to all the events, from a given time (historical events)
queue.events( fromTime: number, (eventName, time, args) => {

});

// The getters also will return the TIME of the event stream.
const snapshot = await queue.getCountsJobs();

```

```js
const cronQueue = new CronQueue('name', {
})

cronWorker.add('jobName', );
```

```js
const priorityQueue = new PriorityQueue('name', {});

```





# Idea for delayed jobs

A delayed job is placed in the queue, with the given timestamp. Queue works as normally.
When the delayed job reaches the tip of the queue, the diff between the created timestamp and the current timestap is calculated and if it is larger or equal than the delay it is executed, otherwise placed on the delayed set.

41 changes: 41 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "bull",
"version": "0.0.0-development",
"description": "Queue for messages and jobs based on Redis",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"source": "src/index.ts",
"author": "Taskforce.sh Inc.",
"license": "MIT",
"scripts": {
"build": "tsc",
"lint": "tslint --project tsconfig.json -c tslint.json 'src/**/*.ts'",
"test": "yarn lint && tsc && mocha './dist/**/*.spec.js' --exit",
"prettier": "prettier --config package.json --write '**/*.js'",
"precommit": "yarn prettier && yarn lint && yarn test",
"semantic-release": "semantic-release"
},
"devDependencies": {
"@commitlint/cli": "^7.2.1",
"@commitlint/config-conventional": "^7.1.2",
"mocha": "^5.2.0",
"prettier": "^1.15.3",
"semantic-release": "^15.13.2",
"tslint": "^5.12.0",
"tslint-eslint-rules": "^5.4.0",
"typescript": "^3.2.2"
},
"prettier": {
"singleQuote": true
},
"husky": {
"hooks": {
"pre-commit": "yarn precommit",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"repository": {
"type": "git",
"url": "https://github.com/taskforcesh/bull.git"
}
}
24 changes: 24 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES2017",
"module": "commonjs",
"outDir": "dist",
"sourceMap": true,
"experimentalDecorators": true,
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strictNullChecks": false,
"baseUrl": ".",
"types": [],
"paths": {
"@/*": ["src/*"]
},
"lib": ["esnext"]
},
"include": ["src/**/*.ts", "tests/**/*.ts"],
"exclude": ["node_modules"]
}
21 changes: 21 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": ["tslint-eslint-rules"],
"rules": {
"no-unnecessary-class": [true, "allow-empty-class"],
"no-use-before-declare": true,
"no-inferrable-types": true,
"semicolon": [true, "always"],
"no-bitwise": false,
"eofline": true,
"no-any": true,
"prefer-const": true,
"forin": false,
"max-line-length": [
true,
{
"limit": 80,
"ignore-pattern": "^import |^export {(.*?)}"
}
]
}
}
Loading

0 comments on commit b0b2863

Please sign in to comment.