Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

full rewrite in typescript #1

Merged
merged 33 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5242736
fix: skip index creation
simllll Sep 19, 2020
8cd1c31
Merge branch 'master' into hokify
simllll Sep 19, 2020
5bc123a
fix(locking): ensure jobs are not locked too greedy
simllll Sep 24, 2020
cf7f5af
chore(typescript-refactoring): step 1 - rename files to ts
simllll Oct 7, 2020
560114f
chore(typescript-refactoring): step 2 - rename to correct files
simllll Oct 7, 2020
8de81c7
chore(typescript-refactoring): step 3 - rewrite content
simllll Oct 7, 2020
e56f434
chore(typescript-refactoring): step 4 - eslint, prettier, package dev…
simllll Oct 7, 2020
57cc824
chore: some test fixes
simllll Oct 8, 2020
8f9873a
chore: fix tests
simllll Oct 8, 2020
47b067a
chore: fix ts tests and package json
simllll Oct 11, 2020
81ba500
chore: makefile fixes for tsnode
simllll Oct 11, 2020
cb63f59
chore: mocha cleanups
simllll Oct 11, 2020
4297be3
build: add prepublish only command
simllll Oct 11, 2020
3bd90dc
fix: export all kind of types
simllll Oct 11, 2020
ef85fc5
fix: allow data type defintions for jobs
simllll Oct 12, 2020
6271781
feat: add queue size to running stats
simllll Oct 12, 2020
4b683e7
chore: releas 4.0.5
simllll Oct 12, 2020
a2e74a9
fix: use new mongo stack
simllll Oct 12, 2020
3160f0d
fix: improve locking and ensure locks are released
simllll Oct 13, 2020
7a8a5bf
fix: allow returing details for status
simllll Oct 13, 2020
68f13aa
chore: release 4.0.8
simllll Oct 13, 2020
d2f3b20
fix: try to solve the locking issue
simllll Oct 13, 2020
5eca4c6
chore: release 4.0.11
simllll Oct 13, 2020
28df211
chore: release 4.0.12
simllll Oct 13, 2020
a6c0356
fix: add typings for events
simllll Oct 13, 2020
5f74603
chore: release 4.0.13
simllll Oct 13, 2020
57ac2db
docs: update readme
simllll Oct 13, 2020
1aa2d4a
fix: add job name again stats output
simllll Oct 14, 2020
a70f500
fix: simplify unlocking and improve logging
simllll Oct 14, 2020
0e82025
fix: not running jobs even though concurrency is not reached
simllll Oct 14, 2020
71ff8a2
chore: 4.0.17
simllll Oct 14, 2020
b248a2b
fix: tests, agenda-instance should have a smaller processEvery
simllll Oct 14, 2020
82a593b
chore: 4.0.18
simllll Oct 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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