Skip to content

Commit

Permalink
add intervals to environment variables
Browse files Browse the repository at this point in the history
Signed-off-by: simvalery <[email protected]>
  • Loading branch information
simvalery committed Dec 3, 2024
1 parent 468fb6c commit 346ebff
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions queue-service/src/queue-service/queue-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@ export class QueueService extends NatsService{
public messageQueueName = 'queue-service';
public replySubject = 'reply-queue-service-' + GenerateUUIDv4();

private readonly refreshInterval = 60 * 1000; // 1m
private readonly processTimeout = 1 * 60 * 60000; // 1 hour
private readonly clearInterval = parseInt(process.env.CLEAR_INTERVAL, 10) || 30 * 1000; // 1m
private readonly refreshInterval = parseInt(process.env.REFRESH_INTERVAL, 10) || 1 * 1000; // 1s
private readonly processTimeout = parseInt(process.env.PROCESS_TIMEOUT, 10) || 1 * 60 * 60000; // 1 hour

public async init() {
await super.init();

// worker job
// worker jobs
setInterval(async () => {
await this.refreshAndReassignTasks();
}, this.refreshInterval);
setInterval(async () => {
await this.clearOldTasks();
await this.clearLongPendingTasks();
}, this.refreshInterval);
}, this.clearInterval);

this.getMessages(QueueEvents.ADD_TASK_TO_QUEUE, (task: ITask) => {
try {
Expand Down

0 comments on commit 346ebff

Please sign in to comment.