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

Add namespace to queues names for external services #7246

Merged
merged 3 commits into from
Sep 20, 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ describe('convertToPdfWorker', () => {

const recreateRedisQueue = async () => {
try {
await redisSMQ.deleteQueueAsync({ qname: 'convert-to-pdf_results' });
await redisSMQ.deleteQueueAsync({ qname: 'development_convert-to-pdf_results' });
} catch (err) {
if (err instanceof Error && err.name !== 'queueNotFound') {
throw err;
}
}
await redisSMQ.createQueueAsync({ qname: 'convert-to-pdf_results' });
await redisSMQ.createQueueAsync({ qname: 'development_convert-to-pdf_results' });
};

beforeAll(async () => {
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('convertToPdfWorker', () => {
};

await redisSMQ.sendMessageAsync({
qname: 'convert-to-pdf_results',
qname: 'development_convert-to-pdf_results',
message: JSON.stringify(message),
});
});
Expand Down Expand Up @@ -162,7 +162,7 @@ describe('convertToPdfWorker', () => {
jest.spyOn(handleError, 'handleError').mockImplementationOnce(() => {});

await redisSMQ.sendMessageAsync({
qname: 'convert-to-pdf_results',
qname: 'development_convert-to-pdf_results',
message: JSON.stringify(message),
});

Expand Down
4 changes: 2 additions & 2 deletions app/api/services/tasksmanager/TaskManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class TaskManager<

constructor(service: Service<T, R>) {
this.service = service;
this.taskQueue = `${service.serviceName}_tasks`;
this.resultsQueue = `${service.serviceName}_results`;
this.taskQueue = `${config.ENVIRONMENT}_${service.serviceName}_tasks`;
this.resultsQueue = `${config.ENVIRONMENT}_${service.serviceName}_results`;
const redisUrl = `redis://${config.redis.host}:${config.redis.port}`;
this.redisClient = Redis.createClient(redisUrl);
this.redisSMQ = new RedisSMQ({ client: this.redisClient });
Expand Down
14 changes: 7 additions & 7 deletions app/api/services/tasksmanager/specs/ExternalDummyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,16 @@ export class ExternalDummyService {
}

async resetQueue() {
await this.deleteQueue(`${this.serviceName}_tasks`);
await this.deleteQueue(`${this.serviceName}_results`);
await this.deleteQueue(`development_${this.serviceName}_tasks`);
await this.deleteQueue(`development_${this.serviceName}_results`);

await this.createQueue(`${this.serviceName}_tasks`);
await this.createQueue(`${this.serviceName}_results`);
await this.createQueue(`development_${this.serviceName}_tasks`);
await this.createQueue(`development_${this.serviceName}_results`);
}

async readFirstTaskMessage() {
const message: RedisSMQ.QueueMessage | {} = await this.rsmq.receiveMessageAsync({
qname: `${this.serviceName}_tasks`,
qname: `development_${this.serviceName}_tasks`,
});
const queueMessage = message as QueueMessage;

Expand All @@ -140,7 +140,7 @@ export class ExternalDummyService {
}

await this.rsmq.deleteMessageAsync({
qname: `${this.serviceName}_tasks`,
qname: `development_${this.serviceName}_tasks`,
id: queueMessage.id,
});

Expand Down Expand Up @@ -186,7 +186,7 @@ export class ExternalDummyService {
async sendFinishedMessage(task: ResultsMessage) {
try {
await this.rsmq.sendMessageAsync({
qname: `${this.serviceName}_results`,
qname: `development_${this.serviceName}_results`,
message: JSON.stringify(task),
});
} catch (err) {
Expand Down
Loading