Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@ryansg.com>2019-12-09 11:40:02 -0500
committerAustin Schaffer <austin.schaffer@ryansg.com>2019-12-12 10:27:09 -0500
commit9d6cb23e161eb333b6a7cbc25fa6db03b1ac10dc (patch)
treec3cf1c73ea707eff43fa7ca518b8d3a52963f550 /src
parentd9ee999adbfbd22ed7a9f67766d0ce243c30bd90 (diff)
downloadliza-9d6cb23e161eb333b6a7cbc25fa6db03b1ac10dc.tar.gz
liza-9d6cb23e161eb333b6a7cbc25fa6db03b1ac10dc.tar.bz2
liza-9d6cb23e161eb333b6a7cbc25fa6db03b1ac10dc.zip
AmqpConnection: Propagate assertExchange promise
Failures were being ignored.
Diffstat (limited to 'src')
-rw-r--r--src/system/DeltaProcessor.ts2
-rw-r--r--src/system/amqp/AmqpConnection.ts32
2 files changed, 17 insertions, 17 deletions
diff --git a/src/system/DeltaProcessor.ts b/src/system/DeltaProcessor.ts
index b136f80..7433bd8 100644
--- a/src/system/DeltaProcessor.ts
+++ b/src/system/DeltaProcessor.ts
@@ -219,4 +219,4 @@ export class DeltaProcessor
return 0;
}
-} \ No newline at end of file
+}
diff --git a/src/system/amqp/AmqpConnection.ts b/src/system/amqp/AmqpConnection.ts
index 13b9791..6d50bfc 100644
--- a/src/system/amqp/AmqpConnection.ts
+++ b/src/system/amqp/AmqpConnection.ts
@@ -17,25 +17,23 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * Amqp Connection
*/
import { AmqpConfig } from '../AmqpPublisher';
import { EventEmitter } from "events";
-import {
- connect as AmqpConnect,
- Channel,
- Connection,
-} from 'amqplib';
-
+import * as amqplib from "amqplib";
+/**
+ * Connection to AMQP exchange
+ *
+ * XXX: Needs tests!
+ */
export class AmqpConnection
{
/** The amqp connection */
- private _conn?: Connection;
+ private _conn?: amqplib.Connection;
/** The amqp channel */
- private _channel?: Channel;
+ private _channel?: amqplib.Channel;
/**
@@ -45,6 +43,7 @@ export class AmqpConnection
* @param _emitter - event emitter instance
*/
constructor(
+ private readonly _amqp: typeof amqplib,
private readonly _conf: AmqpConfig,
private readonly _emitter: EventEmitter,
) {}
@@ -55,7 +54,7 @@ export class AmqpConnection
*/
connect(): Promise<void>
{
- return AmqpConnect( this._conf )
+ return this._amqp.connect( this._conf )
.then( conn =>
{
this._conn = conn;
@@ -72,16 +71,17 @@ export class AmqpConnection
return this._conn.createChannel();
} )
- .then( ( ch: Channel ) =>
+ .then( ( ch: amqplib.Channel ) =>
{
this._channel = ch;
- this._channel.assertExchange(
+ return this._channel.assertExchange(
this._conf.exchange,
'fanout',
{ durable: true }
);
- } );
+ } )
+ .then( _ => {} );
}
@@ -130,7 +130,7 @@ export class AmqpConnection
*
* @return exchange name
*/
- getAmqpChannel(): Channel | undefined
+ getAmqpChannel(): amqplib.Channel | undefined
{
if ( !this._channel )
{
@@ -151,4 +151,4 @@ export class AmqpConnection
this._conn.close.bind(this._conn);
}
}
-} \ No newline at end of file
+}