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

BC-5661 - refactor RabbitMQ configuration #4963

Merged
merged 2 commits into from
Apr 26, 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: 0 additions & 4 deletions apps/server/src/infra/rabbitmq/exchange/files-preview.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import { Configuration } from '@hpi-schul-cloud/commons/lib';

export const FilesPreviewExchange = Configuration.get('FILES_STORAGE__EXCHANGE') as string;

export enum FilesPreviewEvents {
'GENERATE_PREVIEW' = 'generate-preview',
}
3 changes: 0 additions & 3 deletions apps/server/src/infra/rabbitmq/exchange/files-storage.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { Configuration } from '@hpi-schul-cloud/commons/lib';
import { EntityId } from '@shared/domain/types';

export const FilesStorageExchange = Configuration.get('FILES_STORAGE__EXCHANGE') as string;

export enum FilesStorageEvents {
'COPY_FILES_OF_PARENT' = 'copy-files-of-parent',
'LIST_FILES_OF_PARENT' = 'list-files-of-parent',
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/infra/rabbitmq/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './error.mapper';
export * from './exchange';
export * from './rabbitmq.config';
export * from './rabbitmq.module';
export * from './rpc-message';
export * from './rpc-message-producer';
7 changes: 7 additions & 0 deletions apps/server/src/infra/rabbitmq/rabbitmq.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Configuration } from '@hpi-schul-cloud/commons/lib';

export const FilesPreviewExchange = Configuration.get('FILES_STORAGE__EXCHANGE') as string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filesPreviewExchange or FILES_PREVIEW_EXCHANGE ?

And maybe use a class as wrapper to have a namespace "configuration" for it?

export const FilesStorageExchange = Configuration.get('FILES_STORAGE__EXCHANGE') as string;
export const MailSendExchange = Configuration.get('MAIL_SEND_EXCHANGE') as string;
export const AntivirusExchange = Configuration.get('ANTIVIRUS_EXCHANGE') as string;
export const RabbitMqURI = Configuration.get('RABBITMQ_URI') as string;
15 changes: 10 additions & 5 deletions apps/server/src/infra/rabbitmq/rabbitmq.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { AmqpConnectionManager, RabbitMQModule } from '@golevelup/nestjs-rabbitmq';
import { Configuration } from '@hpi-schul-cloud/commons';
import { Global, Module, OnModuleDestroy } from '@nestjs/common';
import { FilesPreviewExchange, FilesStorageExchange } from './exchange';
import {
AntivirusExchange,
FilesPreviewExchange,
FilesStorageExchange,
MailSendExchange,
RabbitMqURI,
} from './rabbitmq.config';

/**
* https://www.npmjs.com/package/@golevelup/nestjs-rabbitmq#usage
Expand All @@ -17,11 +22,11 @@ const imports = [
prefetchCount: 5,
exchanges: [
{
name: Configuration.get('MAIL_SEND_EXCHANGE') as string,
name: MailSendExchange,
type: 'direct',
},
{
name: Configuration.get('ANTIVIRUS_EXCHANGE') as string,
name: AntivirusExchange,
type: 'direct',
},
{
Expand All @@ -33,7 +38,7 @@ const imports = [
type: 'direct',
},
],
uri: Configuration.get('RABBITMQ_URI') as string,
uri: RabbitMqURI,
}),
];
@Global()
Expand Down
Loading