Skip to content

Commit

Permalink
Merge pull request #1 from hokify/typescript
Browse files Browse the repository at this point in the history
full rewrite in typescript
  • Loading branch information
simllll committed Oct 15, 2020
2 parents 481ea77 + 82a593b commit bee9fe7
Show file tree
Hide file tree
Showing 86 changed files with 10,360 additions and 8,419 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
root: true,
extends: ['@hokify'],
parserOptions: {
project: './tsconfig.eslint.json'
}
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ docs/agenda/*
!docs/agenda/2.0.0/
!docs/agenda/2.2.0/
!docs/agenda/3.1.0/
dist
13 changes: 13 additions & 0 deletions .mocharc.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"diff": true,
"spec": "./test/*.test.ts",
"require": ["source-map-support/register"],
"extension": ["js", "ts"],
"package": "./package.json",
"recursive": true,
"reporter": "spec",
"slow": 75,
"timeout": 25000,
"ui": "bdd",
"exit": true
}
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ History.md
Makefile
renovate.json
test
yarn.lock
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"printWidth": 100,
"singleQuote": true,
"useTabs": true,
"trailingComma": "none",
"arrowParens": "avoid"
}
9 changes: 1 addition & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
language: node_js
services: mongodb
sudo: required
node_js:
- 10
- 12
- 14
addons:
apt:
sources:
# gcc 4.8+ requires ubuntu-toolchain-r-test
- ubuntu-toolchain-r-test
- mongodb-upstart
- mongodb-3.4-precise
packages:
# NodeJS v4+ requires gcc 4.8+
- g++-4.9
- gcc-4.9
- mongodb-org-server
- mongodb-org-shell
env:
global:
# NodeJS v4+ requires gcc 4.8+
- CXX=g++-4.9 CC=gcc-4.9
- TRAVIS=true
script: npm test
before_script:
- mongo --version
- mongod --version
after_script: make test-coveralls
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
MOCHA_PATH=node_modules/mocha/bin/mocha

test:
NODE_ENV=test $(MOCHA_PATH) -w --reporter spec
NODE_ENV=test $(MOCHA_PATH) -r ts-node/register -w --reporter spec

test-debug:
NODE_ENV=test $(MOCHA_PATH) -w --reporter spec debug
NODE_ENV=test $(MOCHA_PATH) -r ts-node/register -w --reporter spec debug

test-once:
NODE_ENV=test $(MOCHA_PATH) --reporter spec --timeout 8000 -b
NODE_ENV=test $(MOCHA_PATH) -r ts-node/register --reporter spec --timeout 8000 -b

test-coverage:
NODE_ENV=test AGENDA_COVERAGE=1 $(MOCHA_PATH) test --require blanket --reporter html-cov > coverage.html
NODE_ENV=test AGENDA_COVERAGE=1 $(MOCHA_PATH) -r ts-node/register test --require blanket --reporter html-cov > coverage.html

test-coveralls:
NODE_ENV=test AGENDA_COVERAGE=1 $(MOCHA_PATH) test --require blanket --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js
NODE_ENV=test AGENDA_COVERAGE=1 $(MOCHA_PATH) -r ts-node/register test --require blanket --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js

install:
@npm i
Expand Down
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Typescript rewrite of agendaJS
<p align="center">
<img src="https://cdn.jsdelivr.net/gh/agenda/agenda@master/agenda.svg" alt="Agenda" width="100" height="100">
</p>
Expand All @@ -15,6 +16,15 @@
<br>
</p>

# Fork
This is a fork of agenda js, it differs from the original version in following points:
- Complete rewrite in Typescript (fully typed!)
- Supports mongoDB sharding by name
- touch() can have an optional progress parameter (0-100)
- Bugfixes and improvements for locking
- Breaking change: define() config paramter moved from 2nd position to 3rd
- getRunningStats()

# Agenda offers

- Minimal overhead. Agenda aims to keep its code base small.
Expand Down Expand Up @@ -93,15 +103,15 @@ agenda.define('delete old users', async job => {
```

```js
agenda.define('send email report', {priority: 'high', concurrency: 10}, async job => {
agenda.define('send email report', async job => {
const {to} = job.attrs.data;
await emailClient.send({
to,
from: 'example@example.com',
subject: 'Email Report',
body: '...'
});
});
}, {priority: 'high', concurrency: 10}, );

(async function() {
await agenda.start();
Expand Down Expand Up @@ -337,7 +347,7 @@ await agenda.start();

Before you can use a job, you must define its processing behavior.

### define(jobName, [options], fn)
### define(jobName, fn, [options])

Defines a job with the name of `jobName`. When a job of `jobName` gets run, it
will be passed to `fn(job, done)`. To maintain asynchronous behavior, you may
Expand Down Expand Up @@ -556,9 +566,9 @@ You can configure the locking mechanism by specifying `lockLifetime` as an
interval when defining the job.

```js
agenda.define('someJob', {lockLifetime: 10000}, (job, cb) => {
agenda.define('someJob', (job, cb) => {
// Do something in 10 seconds or less...
});
}, {lockLifetime: 10000});
```

This will ensure that no other job processor (this one included) attempts to run the job again
Expand Down
22 changes: 0 additions & 22 deletions lib/agenda/cancel.js

This file was deleted.

18 changes: 0 additions & 18 deletions lib/agenda/create.js

This file was deleted.

53 changes: 0 additions & 53 deletions lib/agenda/database.js

This file was deleted.

34 changes: 0 additions & 34 deletions lib/agenda/db-init.js

This file was deleted.

15 changes: 0 additions & 15 deletions lib/agenda/default-concurrency.js

This file was deleted.

16 changes: 0 additions & 16 deletions lib/agenda/default-lock-lifetime.js

This file was deleted.

15 changes: 0 additions & 15 deletions lib/agenda/default-lock-limit.js

This file was deleted.

30 changes: 0 additions & 30 deletions lib/agenda/define.js

This file was deleted.

Loading

0 comments on commit bee9fe7

Please sign in to comment.