Merge branch 'propagate' into 'main'
propagate configuration See merge request v3/services/user!12
This commit is contained in:
commit
201934a536
|
@ -6,6 +6,7 @@ import { DeleteConfigurationCommand } from '../../commands/delete-configuration.
|
|||
import { SetConfigurationCommand } from '../../commands/set-configuration.command';
|
||||
import { DeleteConfigurationRequest } from '../../domain/dtos/delete-configuration.request';
|
||||
import { SetConfigurationRequest } from '../../domain/dtos/set-configuration.request';
|
||||
import { Configuration } from '../../domain/entities/configuration';
|
||||
|
||||
@Controller()
|
||||
export class ConfigurationMessagerController {
|
||||
|
@ -17,10 +18,10 @@ export class ConfigurationMessagerController {
|
|||
@RabbitSubscribe({
|
||||
exchange: 'configuration',
|
||||
routingKey: ['create', 'update'],
|
||||
queue: 'configuration-update',
|
||||
queue: 'user-configuration-update',
|
||||
})
|
||||
public async setConfigurationHandler(message: string) {
|
||||
const configuration = JSON.parse(message);
|
||||
const configuration: Configuration = JSON.parse(message);
|
||||
if (
|
||||
configuration.domain ==
|
||||
this._configService.get<string>('SERVICE_CONFIGURATION_DOMAIN')
|
||||
|
@ -39,10 +40,10 @@ export class ConfigurationMessagerController {
|
|||
@RabbitSubscribe({
|
||||
exchange: 'configuration',
|
||||
routingKey: 'delete',
|
||||
queue: 'configuration-delete',
|
||||
queue: 'user-configuration-delete',
|
||||
})
|
||||
public async configurationDeletedHandler(message: string) {
|
||||
const deletedConfiguration = JSON.parse(message);
|
||||
const deletedConfiguration: Configuration = JSON.parse(message);
|
||||
if (
|
||||
deletedConfiguration.domain ==
|
||||
this._configService.get<string>('SERVICE_CONFIGURATION_DOMAIN')
|
||||
|
@ -55,4 +56,28 @@ export class ConfigurationMessagerController {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'configuration',
|
||||
routingKey: 'propagate',
|
||||
queue: 'user-configuration-propagate',
|
||||
})
|
||||
public async propagateConfigurationsHandler(message: string) {
|
||||
const configurations: Array<Configuration> = JSON.parse(message);
|
||||
configurations.forEach(async (configuration) => {
|
||||
if (
|
||||
configuration.domain ==
|
||||
this._configService.get<string>('SERVICE_CONFIGURATION_DOMAIN')
|
||||
) {
|
||||
const setConfigurationRequest: SetConfigurationRequest =
|
||||
new SetConfigurationRequest();
|
||||
setConfigurationRequest.domain = configuration.domain;
|
||||
setConfigurationRequest.key = configuration.key;
|
||||
setConfigurationRequest.value = configuration.value;
|
||||
await this._commandBus.execute(
|
||||
new SetConfigurationCommand(setConfigurationRequest),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import { AutoMap } from '@automapper/classes';
|
||||
|
||||
export class Configuration {
|
||||
@AutoMap()
|
||||
uuid: string;
|
||||
|
||||
@AutoMap()
|
||||
domain: string;
|
||||
|
||||
|
|
Loading…
Reference in New Issue