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

feat(queue-events): pass debounceId as a param of debounced event #2678

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/classes/queue-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export interface QueueEventsListener extends IoredisListener {
/**
* Listen to 'debounced' event.
*
* This event is triggered when a job is debounced because debouncedId still existed.
* This event is triggered when a job is debounced because debounceId still existed.
*/
debounced: (args: { jobId: string }, id: string) => void;
debounced: (args: { jobId: string; debounceId: string }, id: string) => void;

/**
* Listen to 'delayed' event.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/includes/debounceJob.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local function debounceJob(prefixKey, debounceOpts, jobId, debounceKey, eventsKe
if debounceKeyExists then
local currentDebounceJobId = rcall('GET', debounceKey)
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
"debounced", "jobId", currentDebounceJobId)
"debounced", "jobId", currentDebounceJobId, "debounceId", debounceId)
return currentDebounceJobId
end
end
Expand Down
4 changes: 3 additions & 1 deletion tests/test_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,13 @@ describe('events', function () {

let debouncedCounter = 0;
let secondJob;
queueEvents.on('debounced', ({ jobId }) => {
queueEvents.on('debounced', ({ jobId, debounceId }) => {
if (debouncedCounter > 1) {
expect(jobId).to.be.equal(secondJob.id);
expect(debounceId).to.be.equal('a1');
} else {
expect(jobId).to.be.equal(job.id);
expect(debounceId).to.be.equal('a1');
}
debouncedCounter++;
});
Expand Down
Loading