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

Version 2 (published as next to NPM) #57

Open
wants to merge 121 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
84de5c2
merge in v2 initial changes
ryanwitt Dec 14, 2023
c58b9c6
add github actions
ryanwitt Dec 15, 2023
76c7672
fix syntax, add redis and codecov
ryanwitt Dec 15, 2023
2368f25
fix broken --version flag on global install
ryanwitt Dec 15, 2023
f7d5f48
add the --archive flag for draining jobs to stdout
ryanwitt Dec 16, 2023
5ad38f7
update module entry, add sentry to build process
ryanwitt Dec 19, 2023
05860e3
change to using sha as version, separate matrix and coverage steps
ryanwitt Dec 19, 2023
f994958
add missing runs-on
ryanwitt Dec 19, 2023
d9599bb
fix test and rename workflow
ryanwitt Dec 19, 2023
8db04c8
add consumer and example
ryanwitt Dec 20, 2023
343f99c
update examples
ryanwitt Dec 21, 2023
236d0cc
improve processMessage ux, cleanup examples, add callback feature
ryanwitt Dec 21, 2023
d0a2a33
implement --tag option
ryanwitt Dec 21, 2023
0c27585
sentrify worker
ryanwitt Dec 21, 2023
e6126db
fix prefix bug
ryanwitt Dec 22, 2023
142c425
really fix it
ryanwitt Dec 22, 2023
576cd12
bugfix for empty result from SQS
ryanwitt Dec 27, 2023
188de73
proper default handling
ryanwitt Dec 27, 2023
2611467
add a commonjs export
ryanwitt Dec 28, 2023
89f3c27
fix tests
ryanwitt Dec 28, 2023
bec21f9
add shrinkwrap and specify files to be published
ryanwitt Dec 28, 2023
47fdb60
missing index.js
ryanwitt Dec 28, 2023
9f3fee7
v2.0.2-alpha
ryanwitt Dec 29, 2023
3c4acff
v2.0.3-alpha
ryanwitt Dec 29, 2023
b389602
add --fail-delay option for delay on entire queue, update docs
ryanwitt Dec 29, 2023
5c458b5
prep for 2.0.4-alpha publish
ryanwitt Dec 29, 2023
2f2cec4
bugfix that TypeScript would have caught
ryanwitt Jan 5, 2024
a169569
initial attempt at pulling retries into qdone
ryanwitt Jan 7, 2024
0ed1d1e
bugfix for idle-queues
ryanwitt Jan 8, 2024
a33f7f9
better handling for Failed batch memebers, handle QDnE errors
ryanwitt Jan 8, 2024
1800a89
bump version
ryanwitt Jan 8, 2024
9bc6c3e
fix for rare shared message buffers bug
ryanwitt Jan 9, 2024
239d591
bump to 2.0.8-alpha
ryanwitt Jan 9, 2024
cf31f08
consumer update
ryanwitt Jan 10, 2024
bdb2e51
bump to 2.0.9-alpha
ryanwitt Jan 10, 2024
c6da219
latency experiments
ryanwitt Jan 11, 2024
b2d346a
scheduler work
ryanwitt Jan 12, 2024
6164caf
prep for 2.0.10-alpha release
ryanwitt Jan 12, 2024
3c1671f
lint
ryanwitt Jan 12, 2024
92835da
fixes
ryanwitt Jan 12, 2024
fa52088
fix success reporting
ryanwitt Jan 12, 2024
9b58ab9
qdone 2.0.12-alpha
ryanwitt Jan 12, 2024
44957f3
version 2.0.13-alpha
ryanwitt Jan 12, 2024
68cdc3a
fixes
ryanwitt Jan 17, 2024
48b0fdc
release 2.0.14-alpha
ryanwitt Jan 17, 2024
2702431
version 2.0.15-alpha
ryanwitt Jan 18, 2024
baff00f
release v2.0.16-alpha sentry support
ryanwitt Jan 18, 2024
0bf94e4
release 2.0.17-alpha memory control system tuning
ryanwitt Jan 19, 2024
40178cd
fixes #58
ryanwitt Jan 19, 2024
b1bf30d
release 2.0.18-alpha
ryanwitt Jan 19, 2024
553afd2
release 2.0.19-alpha add memory percent argument
ryanwitt Jan 19, 2024
c4b69f6
release 2.0.20-alpha monitor export
ryanwitt Jan 20, 2024
dbc4331
2.0.21-alpha lockfile compatibility with esm bullshit
ryanwitt Jan 21, 2024
0a20b2e
release 2.0.22-alpha allow dual fifo/non fifo if --fifo not set
ryanwitt Jan 21, 2024
62d235f
release 2.0.23-alpha failed jobs put backpressure on queue
ryanwitt Jan 22, 2024
cf2ebd9
release 2.0.26-alpha add load to calculation
ryanwitt Jan 22, 2024
d3257be
release 2.0.27-alpha bug fixes, improvements from field testing
ryanwitt Jan 23, 2024
56d83f2
release 2.0.28-alpha bugfix for long running jobs
ryanwitt Jan 23, 2024
1481073
2.0.29-alpha don't icehouse failed jobs, fix icehouse bug, exclude _dead
ryanwitt Jan 24, 2024
63de8fc
release 2.0.30-alpha fix fifo processing, dlq defaults
ryanwitt Feb 2, 2024
7c5cbfd
release 2.0.31-alpha bugfix and only count running jobs in total
ryanwitt Feb 2, 2024
c1e0444
release v2.0.32-alpha minor visual fixes, corner cases
ryanwitt Feb 2, 2024
27a71d4
release v2.0.33-alpha minor bugfix
ryanwitt Feb 2, 2024
70807a4
release 2.0.34-alpha bugfixes and fairness improvement
ryanwitt Feb 2, 2024
c20c3a0
release v2.0.34-alpha
ryanwitt Feb 2, 2024
75d35b6
release 2.0.35-alpha add --include-dead option
ryanwitt Feb 9, 2024
e697ccb
dedup branch
ryanwitt Mar 12, 2024
1df351c
fix tests, fix multi
ryanwitt Mar 13, 2024
a0de993
rework to solve several issues
ryanwitt Mar 17, 2024
07c88c2
placeholder
ryanwitt Mar 18, 2024
1f253e4
feedback from PR review, 100% coverage
ryanwitt Mar 20, 2024
ab5dbb8
Merge pull request #61 from suredone/dedup
jasonspalace Mar 20, 2024
a080150
check in the finally debugged initial version of check command
ryanwitt Mar 6, 2024
9fccc19
fix tests
ryanwitt Mar 24, 2024
43e00ba
Merge pull request #62 from suredone/check-command
ryanwitt Mar 25, 2024
9f7226f
cleanup, allow per-message options
ryanwitt Mar 25, 2024
8fa04a9
add extra sentry context
ryanwitt Mar 25, 2024
c7f61f2
Merge pull request #63 from suredone/sentry-context
ryanwitt Mar 25, 2024
b05d16c
checkin version bump
ryanwitt Mar 29, 2024
000b321
fix issue with cluster incompatibility
ryanwitt Mar 29, 2024
c41835e
more fixes from testing
ryanwitt Apr 1, 2024
b0620b6
more fixes from testing
ryanwitt Apr 2, 2024
b9366dc
use better spread for redis
ryanwitt Apr 3, 2024
d0f6147
fix for suredone/suredone#10215
ryanwitt Apr 3, 2024
1d42c5d
release 2.0.40-alpha
ryanwitt Apr 3, 2024
d0f2cb4
move hash to beginning to fix spread issue when payload uses {}
ryanwitt Apr 4, 2024
e672761
transform passed deduplication ids
ryanwitt Apr 4, 2024
21d193b
improve test coverage
ryanwitt Apr 15, 2024
e0b3ca5
fix bug where failed change/deletes were kept around, tuning
ryanwitt May 14, 2024
970f057
version 2.0.43-alpha
ryanwitt May 15, 2024
c5df5f4
v2.0.44-alpha bugfix release
ryanwitt May 17, 2024
4c4e26e
jobExecutor bugfix
ryanwitt May 21, 2024
1bd065c
v2.0.45-alpha
ryanwitt May 21, 2024
0bd632f
v2.0.46-alpha
ryanwitt May 21, 2024
b2378b2
wip on returning deduplicaiton ids to caller
ryanwitt May 10, 2024
a83a1ff
fix testing issues and one bug
ryanwitt Jun 7, 2024
0b4c9f7
prep next for testing with new dedup id return
ryanwitt Jun 12, 2024
fb5739a
bugfixes
ryanwitt Jun 17, 2024
efb72b9
Merge pull request #64 from suredone/return-deduplication-ids
jasonspalace Jun 18, 2024
7b1aae5
wip changes to include DLQ in deletion
ryanwitt Jun 7, 2024
95703f4
long time to get that working
ryanwitt Jul 8, 2024
bec4790
Merge pull request #66 from suredone/delete-idle-queues-2
ryanwitt Jul 8, 2024
bbf2536
idle queue deletion
ryanwitt Jul 8, 2024
f9d973e
add environment variable options and tests
ryanwitt Jul 9, 2024
2100e4b
bump version
ryanwitt Jul 9, 2024
3f7a60f
respect prefix for monitor command
ryanwitt Jul 9, 2024
4e51985
bump version
ryanwitt Jul 9, 2024
037479d
fix monitor bug, delete orphaned idle queues, validate more strings
ryanwitt Jul 10, 2024
dd9effb
remove references to unpair
ryanwitt Jul 11, 2024
9cbd368
bump version
ryanwitt Jul 11, 2024
0be5198
results from live testing
ryanwitt Aug 21, 2024
d915f41
Merge pull request #68 from suredone/cache-and-load
ryanwitt Aug 21, 2024
68d3262
bump version
ryanwitt Aug 21, 2024
d82b417
bugfix and test coverage
ryanwitt Sep 8, 2024
a1876c0
2.0.54-alpha
ryanwitt Sep 8, 2024
0bf34e4
update tests
ryanwitt Sep 8, 2024
d385ec3
more tests
ryanwitt Sep 8, 2024
578bae4
Merge pull request #67 from suredone/monitor-fixes
ryanwitt Sep 8, 2024
cbef94d
faster ramp up, allow multiple jobs from the same queue
ryanwitt Sep 10, 2024
0c1a6c2
a little cleaner
ryanwitt Sep 10, 2024
1302573
v2.0.55-alpha
ryanwitt Sep 10, 2024
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
91 changes: 91 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Build

on: [push]

env:
NODE_OPTIONS: --max_old_space_size=4096

jobs:

test:
name: Test
strategy:
matrix:
version: [16, 18, 20]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
services:
redis:
image: redis
ports:
- 6379:6379
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=5
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.version }}
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install
- run: npm test

build:
name: Coverage and Sentry
needs: [test]
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=5
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.version }}
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install
- run: npm test -- --coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Create Sentry release
uses: getsentry/[email protected]
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: suredone
SENTRY_PROJECT: qdone
with:
version: ${{ github.sha }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
node_modules/
.nyc_output/
coverage
.DS_Store
*.swp
commonjs/src
commonjs/*.js
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ Options
option if you are managing retries outside of qdone, and make sure the ID is
the same for each retry in the deduplication window. Defaults to a string
unique to this invocation.
-d, --delay number Delays delivery of each message by the given number of seconds (up to 900 seconds,
or 15 minutes). Defaults to immediate delivery (no delay).
--dlq-after number Sends messages from the failed queue to a dead letter queue after this many failures. [default: 3]
--dlq-suffix string Suffix to append to each queue to generate DLQ name [default: _dead]
--prefix string Prefix to place at the front of each SQS queue name [default: qdone_]
--fail-suffix string Suffix to append to each queue to generate fail queue name [default: _failed]
--region string AWS region for Queues [default: us-east-1]
Expand Down Expand Up @@ -482,4 +486,4 @@ If a queue name ends with the * (wildcard) character, worker will listen on all
-q, --quiet Turn on production logging. Automatically set if stderr is not a tty.
-v, --verbose Turn on verbose output. Automatically set if stderr is a tty.
-V, --version Show version number
--help Print full help message.
--help Print full help message.
3 changes: 3 additions & 0 deletions commonjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
16 changes: 16 additions & 0 deletions examples/processMessage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env -S node --experimental-json-modules
//
// This example enqueues three messages and processes them.
//
import { enqueue, processMessages, requestShutdown } from '../index.mjs' // from 'qdone' for standalone example

await enqueue('test1', JSON.stringify({ one: 1 }))
await enqueue('test2', JSON.stringify({ two: 2 }))
await enqueue('test3', JSON.stringify({ three: 3 }))

async function callback (queue, payload) {
console.log({ queue, payload })
if (payload.three) requestShutdown()
}

await processMessages(['test1', 'test2', 'test3'], callback)
19 changes: 19 additions & 0 deletions examples/processMessageRandom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env -S node --experimental-json-modules
//
// This example processes random messages once a second until you Ctl-C
//

import { enqueue, processMessages, requestShutdown } from '../index.mjs' // from 'qdone' for standalone example

const randomEnqueue = setInterval(function () {
enqueue(['rtest1', 'rtest2', 'rtest3'][Math.round(Math.random() * 2)], JSON.stringify({ foo: Math.round(Math.random() * 10) }))
}, 1000)

process.on('SIGINT', () => { clearInterval(randomEnqueue); console.log('SIGINT'); requestShutdown() })
process.on('SIGTERM', () => { clearInterval(randomEnqueue); console.log('SIGTERM'); requestShutdown() })

async function callback (queue, payload) {
console.log({ queue, payload })
}

await processMessages(['rtest1', 'rtest2', 'rtest3'], callback, { verbose: true, disableLog: true })
49 changes: 49 additions & 0 deletions examples/simpleScheduler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env -S node --experimental-json-modules

//
// This example implements a basic scheduler on top of qdone. The
// processMessages callback looks at the queue name throws a DoNotProcess
// error if there are already two messages processing on this queue.
//

import {
enqueue,
processMessages,
requestShutdown,
DoNotProcess
} from '../index.mjs' // from 'qdone' for standalone example

const randomEnqueue = setInterval(function () {
const queue = ['rtest1', 'rtest2', 'rtest3'][Math.round(Math.random() * 2)]
const payload = { foo: Math.round(Math.random() * 10) }
console.log({ enqueue: { queue, payload } })
enqueue(queue, JSON.stringify(payload))
}, 200)

process.on('SIGINT', () => { clearInterval(randomEnqueue); console.log('SIGINT'); requestShutdown() })
process.on('SIGTERM', () => { clearInterval(randomEnqueue); console.log('SIGTERM'); requestShutdown() })

// This returns a promise that resolves in the given number of milliseconds
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms))

// This keeps track of the number of active jobs per queue
const activeCount = {}

async function callback (queue, payload) {
const numActive = activeCount[queue] = (activeCount[queue] || 0) + 1
console.log({ numActive, activeCount })
try {
// Limit to 2 active tasks per queue
if (numActive > 2) {
console.log({ refusing: { queue, payload } })
throw new DoNotProcess()
}

console.log({ processing: { queue, payload } })
await delay(Math.random() * 1000 * 2) // Processing takes up to 2 seconds
} finally {
activeCount[queue] = (activeCount[queue] || 0) - 1
}
}

await processMessages(['rtest1', 'rtest2', 'rtest3'], callback, { verbose: true, disableLog: true })
8 changes: 2 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@

module.exports = {
enqueue: require('./src/enqueue'),
worker: require('./src/worker'),
cli: require('./src/cli')
}
export { enqueue, enqueueBatch } from './src/enqueue.js'
export { processMessages, requestShutdown, DoNotProcess } from './src/consumer.js'
Loading