Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Commit

Permalink
Merge e091ed9 into c2d19d8
Browse files Browse the repository at this point in the history
  • Loading branch information
jpwilliams committed Dec 1, 2017
2 parents c2d19d8 + e091ed9 commit 84056c0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/Remit.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const url = require('url')
const amqplib = require('amqplib')
const EventEmitter = require('eventemitter3')
const packageJson = require('../package.json')
const parseAmqpUrl = require('../utils/parseAmqpUrl')
const generateConnectionOptions = require('../utils/generateConnectionOptions')
const ChannelPool = require('../utils/ChannelPool')
const CallableWrapper = require('../utils/CallableWrapper')
const throwAsException = require('../utils/throwAsException')
const Endpoint = require('./Endpoint')
const Listener = require('./Listener')
const Request = require('./Request')
Expand All @@ -26,7 +28,7 @@ class Remit {
this._options.url = options.url || process.env.REMIT_URL || 'amqp://localhost'

this._emitter = new EventEmitter()
this._connection = this._connect(this._options)
this._connection = this._connect(this._options).catch(throwAsException)
this._workers = ChannelPool(this._connection)

// TODO make this better
Expand All @@ -37,9 +39,11 @@ class Remit {
this._emitter.on(...args)
}

async _connect ({ url, name, exchange }) {
const amqpUrl = parseAmqpUrl(url)
async _connect ({ url: unparsedUrl, name, exchange }) {
const amqpUrl = parseAmqpUrl(unparsedUrl)
const connectionOptions = generateConnectionOptions(name)
const { hostname } = url.parse(amqpUrl)
connectionOptions.servername = hostname
const connection = await amqplib.connect(amqpUrl, connectionOptions)

const tempChannel = await connection.createChannel()
Expand Down

0 comments on commit 84056c0

Please sign in to comment.