Skip to content

Commit

Permalink
Add assert option
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinegomez committed Oct 31, 2018
1 parent 3cd2987 commit ed9ca09
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -453,6 +453,8 @@ To set up your development environment:
[Back to top](#table-of-contents)

## Change History
* v1.6.0 (2018-10-31)
* Add assert option in Exchange and Queue decorator to allow to disable assert during bootstrap
* v1.5.1 (2018-09-24)
* Fix reconnection error: use once instad of on and rebind event correctly
* v1.5.0 (2018-08-24)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@hapiness/rabbitmq",
"version": "1.5.2",
"version": "1.6.0",
"description": "Hapiness module for rabbitmq",
"main": "commonjs/index.js",
"types": "index.d.ts",
Expand Down
2 changes: 2 additions & 0 deletions src/module/decorators/exchange.decorator.ts
Expand Up @@ -8,11 +8,13 @@ export interface ExchangeDecoratorInterface {
options?: Options.AssertExchange;
channel?: ChannelOptions;
providers?: Array<Type<any> | any>;
assert?: boolean;
}
export const Exchange: CoreDecorator<ExchangeDecoratorInterface> = createDecorator<ExchangeDecoratorInterface>('Exchange', {
name: undefined,
type: undefined,
options: undefined,
channel: undefined,
providers: [],
assert: true,
});
2 changes: 2 additions & 0 deletions src/module/decorators/queue.decorator.ts
Expand Up @@ -10,6 +10,7 @@ export interface QueueDecoratorInterface {
channel?: ChannelOptions;
force_json_decode?: boolean;
providers?: Array<Type<any> | any>;
assert?: boolean;
}
export const Queue: CoreDecorator<QueueDecoratorInterface> = createDecorator<QueueDecoratorInterface>('Queue', {
name: undefined,
Expand All @@ -18,4 +19,5 @@ export const Queue: CoreDecorator<QueueDecoratorInterface> = createDecorator<Que
channel: undefined,
force_json_decode: false,
providers: [],
assert: true,
});
2 changes: 1 addition & 1 deletion src/module/extension/build-exchange.ts
Expand Up @@ -17,7 +17,7 @@ export default function buildExchanges(modules: CoreModule[], connection: Connec
.map(instance => ({ instance, _module, metadata })))
.flatMap(({ instance, _module, metadata }) => {
const exchange = new ExchangeManager(connection.defaultChannel, new ExchangeWrapper(instance, metadata.data));
return exchange.assert();
return metadata.data.assert ? exchange.assert() : Observable.of(exchange);
})
.toArray();
}
3 changes: 2 additions & 1 deletion src/module/extension/build-queues.ts
Expand Up @@ -30,7 +30,8 @@ export default function buildQueues(
Observable.of({ instance, metadata, channel: connection.defaultChannelManager, _module }))
.mergeMap(({ instance, metadata, channel, _module }) => {
const queue = new QueueManager(channel, new QueueWrapper(instance, metadata.data));
return Observable.forkJoin(queue.assert(), Observable.of(metadata), Observable.of(_module));
return Observable
.forkJoin(metadata.data.assert ? queue.assert() : Observable.of(queue), Observable.of(metadata), Observable.of(_module));
})
// Bind queue
.mergeMap(([queue, metadata, _module]) => {
Expand Down

0 comments on commit ed9ca09

Please sign in to comment.