Skip to content

Commit

Permalink
feat: added redis bgrewriteaof command to one time job
Browse files Browse the repository at this point in the history
  • Loading branch information
mckrava committed Apr 3, 2024
1 parent 8701508 commit 8d098b1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/modules/aggregatorStateManager/oneTimeJobsManager.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ type OneTimeJob = { id: string; action: string } & {

const oneTimeJobsList: OneTimeJob[] = [
{
id: '1710336390625',
id: '1712148386341',
action: 'removeAllActiveJobs',
payload: {},
},
{
id: '1712148398499',
action: 'redisBgrewriteaof',
payload: {},
},
];

@Injectable()
Expand Down Expand Up @@ -78,6 +83,22 @@ export class OneTimeJobsManagerService {
}
break;
}
case 'redisBgrewriteaof': {
try {
await this.datasourceHandlingProducer.refreshRedisAofFile();

processedJobs.push(jobId);
console.log(
`OneTime Jobs :: OneTime Job has been completed with details: [id: ${jobDetails.id} // action: ${jobDetails.action}]`,
);
} catch (e) {
console.log(
`OneTime Jobs :: OneTime Job ${jobId} has been processed with error.`,
);
console.log(e);
}
break;
}

default:
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ export class DatasourceHandlingProducer {
}
}

/**
* Command BGREWRITEAOF can be executed from any Redis DB connection client
* and it will have effect to global appendonly.aof file
*/
async refreshRedisAofFile() {
await this.datasourceHandlingQueue.client.bgrewriteaof((err, result) => {
console.log(`bgrewriteaof :: err `, err);
console.log(`bgrewriteaof :: result `, result);
});
}

//
// async enqueueAndWaitCollectTransferEventDataChunkJobProducer(
// requestData: CollectEventDataChunkFromDataSourceInput,
Expand Down

0 comments on commit 8d098b1

Please sign in to comment.