Skip to content

Commit

Permalink
feat(queue): add option to skip metas update
Browse files Browse the repository at this point in the history
  • Loading branch information
manast committed Oct 18, 2024
1 parent dff47c0 commit b7dd925
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/classes/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ export class Queue<

this.waitUntilReady()
.then(client => {
if (!this.closing) {
client.hmset(this.keys.meta, this.metaValues);
if (!this.closing && !opts?.skipMetasUpdate) {
return client.hmset(this.keys.meta, this.metaValues);
}
})
.catch(err => {
Expand Down
13 changes: 13 additions & 0 deletions src/interfaces/queue-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ export interface QueueOptions extends QueueBaseOptions {
};
};

/**
* Skip Meta update.
*
* If true, the queue will not update the metadata of the queue.
* Useful for read-only systems that do should not update the metadata.
*
* @defaultValue false
*/
skipMetasUpdate?: boolean;

/**
* Advanced options for the repeatable jobs.
*/
settings?: AdvancedRepeatOptions;
}

Expand Down
9 changes: 9 additions & 0 deletions tests/test_queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ describe('queues', function () {
return queue.close();
});

it('should return default library version when using skipMetasUpdate', async () => {
const exQueueName = `test-${v4()}`;
const queue = new Queue(exQueueName, { connection, skipMetasUpdate: true });
const version = await queue.getVersion();
expect(version).to.be.equal(null);
await queue.close();
await removeAllQueueData(new IORedis(redisHost), exQueueName);
});

describe('.add', () => {
describe('when jobId is provided as integer', () => {
it('throws error', async function () {
Expand Down

0 comments on commit b7dd925

Please sign in to comment.