Skip to content

Commit

Permalink
refactor assert options
Browse files Browse the repository at this point in the history
  • Loading branch information
tunderdomb committed Aug 1, 2022
1 parent 3d05c16 commit e25f281
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 33 deletions.
7 changes: 2 additions & 5 deletions src/GatheringClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ class GatheringClient {
this._assertExchange = assertExchange === true
this._assertExchangeOptions = null

this._assertQueueOptions = Object.assign(assertQueueOptions || {}, { exclusive: true })

if (this._assertExchange) {
this._assertExchangeOptions = Object.assign(assertExchangeOptions || {}, { durable: true })
}
this._assertQueueOptions = Object.assign({ exclusive: true }, assertQueueOptions || {})
this._assertExchangeOptions = Object.assign({ durable: true }, assertExchangeOptions || {})
}

async initialize () {
Expand Down
10 changes: 2 additions & 8 deletions src/GatheringServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@ class GatheringServer {
this._responseTimeoutMs = timeoutMs
this._assertExchange = assertExchange === true
this._assertExchangeOptions = null

this._assertQueueOptions = assertQueueOptions
? Object.assign(assertQueueOptions || {}, { exclusive: true })
: { exclusive: true } // defaults

if (this._assertExchange) {
this._assertExchangeOptions = Object.assign(assertExchangeOptions || {}, { durable: true })
}
this._assertQueueOptions = Object.assign({ exclusive: true }, assertQueueOptions || {})
this._assertExchangeOptions = Object.assign({ durable: true }, assertExchangeOptions || {})

this.actions = new Map()
}
Expand Down
10 changes: 4 additions & 6 deletions src/Publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ class Publisher {
assertExchange = true,
assertExchangeOptions = null
} = options || {}
this._assertExchange = null
if (assertExchange) {
const defaults = { durable: true }
this._assertExchange = assertExchange === true
this._assertExchangeOptions = assertExchangeOptions || defaults
}

this._assertExchange = assertExchange === true
this._assertExchangeOptions = Object.assign({ durable: true }, assertExchangeOptions || {})

this.MessageModel = MessageModel || QueueMessage
this.ContentSchema = ContentSchema || JSON
}
Expand Down
4 changes: 1 addition & 3 deletions src/QueueClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ class QueueClient extends Publisher {
} = options || {}

this._assertQueue = assertQueue === true
if (this._assertQueue) {
this._assertQueueOptions = Object.assign(assertQueueOptions || {}, { durable: true })
}
this._assertQueueOptions = Object.assign({ durable: true }, assertQueueOptions || {})
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/QueueServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class QueueServer extends Subscriber {
this._prefetchCount = prefetchCount

this._assertQueue = assertQueue === true
if (this._assertQueue) {
this._assertQueueOptions = Object.assign(assertQueueOptions || {}, { durable: true })
}
this._assertQueueOptions = Object.assign({ durable: true }, assertQueueOptions || {})
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/RPCClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ class RPCClient {
this._correlationIdMap = new Map()

this._assertReplyQueue = assertReplyQueue === true
if (this._assertReplyQueue) {
this._assertReplyQueueOptions = Object.assign(assertReplyQueueOptions || {}, { exclusive: true })
}
this._assertReplyQueueOptions = Object.assign({ exclusive: true }, assertReplyQueueOptions || {})

this._rpcQueueMaxSize = queueMaxSize
this._rpcTimeoutMs = timeoutMs
Expand Down
8 changes: 3 additions & 5 deletions src/Subscriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ class Subscriber {
this._timeoutMs = timeoutMs
this.MessageModel = MessageModel || QueueMessage
this.ContentSchema = ContentSchema || JSON
this._assertQueueOptions = Object.assign(assertQueueOptions || {}, { exclusive: true })

this._assertQueueOptions = Object.assign({ exclusive: true }, assertQueueOptions || {})
this._assertExchange = assertExchange === true
if (assertExchange) {
const defaults = { durable: true }
this._assertExchangeOptions = assertExchangeOptions || defaults
}
this._assertExchangeOptions = Object.assign({ durable: true }, assertExchangeOptions || {})

this._retryMap = new Map()

Expand Down

0 comments on commit e25f281

Please sign in to comment.