+8
-0
| Changelog | ||
| ========= | ||
| # 2.0.0 | ||
| ## Breaking changes | ||
| - `createShovel` has changed signature: last argument `cloneMessage` is converted to an `args` object, and `cloneMessage` moved to a property of `args` | ||
| ## Additions | ||
| - Introduce e2e by `bindExchange` and consequentaly `unbindExchange`, shoveling messages between exchanges | ||
| # 1.11.1 | ||
@@ -5,0 +13,0 @@ |
+31
-2
@@ -253,5 +253,34 @@ "use strict"; | ||
| function bindExchange() {} | ||
| function bindExchange(source, destination, pattern = '#', args = {}) { | ||
| const name = `e2e-${source}2${destination}-${pattern}`; | ||
| const { | ||
| consumerTag, | ||
| on: onShovel, | ||
| close: onClose, | ||
| source: shovelSource | ||
| } = createShovel(name, { | ||
| broker, | ||
| exchange: source, | ||
| pattern, | ||
| consumerTag: `smq.ctag-${name}` | ||
| }, { | ||
| broker, | ||
| exchange: destination | ||
| }, { ...args | ||
| }); | ||
| return { | ||
| name, | ||
| source, | ||
| destination, | ||
| queue: shovelSource.queue, | ||
| consumerTag, | ||
| on: onShovel, | ||
| close: onClose | ||
| }; | ||
| } | ||
| function unbindExchange() {} | ||
| function unbindExchange(source, destination, pattern = '#') { | ||
| const name = `e2e-${source}2${destination}-${pattern}`; | ||
| return closeShovel(name); | ||
| } | ||
@@ -258,0 +287,0 @@ function publish(exchangeName, routingKey, content, options) { |
+11
-5
@@ -10,3 +10,3 @@ "use strict"; | ||
| function Shovel(name, source, destination, cloneMessage) { | ||
| function Shovel(name, source, destination, options = {}) { | ||
| const { | ||
@@ -22,2 +22,5 @@ broker: sourceBroker, | ||
| } = destination; | ||
| const { | ||
| cloneMessage | ||
| } = options; | ||
| const sourceExchange = sourceBroker.getExchange(sourceExchangeName); | ||
@@ -35,3 +38,4 @@ | ||
| const consumerTag = `smq.shoveltag-${name}`; | ||
| const sameBroker = sourceBroker === destinationBroker; | ||
| const consumerTag = source.consumerTag || `smq.shoveltag-${name}`; | ||
| const routingKeyPattern = pattern || '#'; | ||
@@ -77,5 +81,7 @@ const events = (0, _Exchange.EventExchange)(); | ||
| } = messageHandler(message); | ||
| destinationExchange.publish(routingKey, content, { ...properties, | ||
| 'shovel-name': name | ||
| }); | ||
| const props = { ...properties, | ||
| 'source-exchange': sourceExchangeName | ||
| }; | ||
| if (!sameBroker) props['shovel-name'] = name; | ||
| destinationExchange.publish(routingKey, content, props); | ||
| message.ack(); | ||
@@ -82,0 +88,0 @@ } |
+3
-2
| { | ||
| "name": "smqp", | ||
| "version": "1.11.1", | ||
| "version": "2.0.0", | ||
| "description": "Synchronous message queuing package", | ||
@@ -55,3 +55,4 @@ "author": { | ||
| "topic", | ||
| "direct" | ||
| "direct", | ||
| "shovel" | ||
| ], | ||
@@ -58,0 +59,0 @@ "devDependencies": { |
+29
-2
@@ -238,5 +238,32 @@ import {Exchange, EventExchange} from './Exchange'; | ||
| function bindExchange() {} | ||
| function unbindExchange() {} | ||
| function bindExchange(source, destination, pattern = '#', args = {}) { | ||
| const name = `e2e-${source}2${destination}-${pattern}`; | ||
| const {consumerTag, on: onShovel, close: onClose, source: shovelSource} = createShovel(name, { | ||
| broker, | ||
| exchange: source, | ||
| pattern, | ||
| consumerTag: `smq.ctag-${name}`, | ||
| }, { | ||
| broker, | ||
| exchange: destination | ||
| }, { | ||
| ...args | ||
| }); | ||
| return { | ||
| name, | ||
| source, | ||
| destination, | ||
| queue: shovelSource.queue, | ||
| consumerTag, | ||
| on: onShovel, | ||
| close: onClose, | ||
| }; | ||
| } | ||
| function unbindExchange(source, destination, pattern = '#') { | ||
| const name = `e2e-${source}2${destination}-${pattern}`; | ||
| return closeShovel(name); | ||
| } | ||
| function publish(exchangeName, routingKey, content, options) { | ||
@@ -243,0 +270,0 @@ const exchange = getExchangeByName(exchangeName); |
+7
-3
| import {EventExchange} from './Exchange'; | ||
| export function Shovel(name, source, destination, cloneMessage) { | ||
| export function Shovel(name, source, destination, options = {}) { | ||
| const {broker: sourceBroker, exchange: sourceExchangeName, pattern, queue} = source; | ||
| const {broker: destinationBroker, exchange: destinationExchangeName} = destination; | ||
| const {cloneMessage} = options; | ||
@@ -17,3 +18,4 @@ const sourceExchange = sourceBroker.getExchange(sourceExchangeName); | ||
| const consumerTag = `smq.shoveltag-${name}`; | ||
| const sameBroker = sourceBroker === destinationBroker; | ||
| const consumerTag = source.consumerTag || `smq.shoveltag-${name}`; | ||
| const routingKeyPattern = pattern || '#'; | ||
@@ -55,3 +57,5 @@ const events = EventExchange(); | ||
| const {content, properties} = messageHandler(message); | ||
| destinationExchange.publish(routingKey, content, {...properties, 'shovel-name': name}); | ||
| const props = {...properties, 'source-exchange': sourceExchangeName}; | ||
| if (!sameBroker) props['shovel-name'] = name; | ||
| destinationExchange.publish(routingKey, content, props); | ||
| message.ack(); | ||
@@ -58,0 +62,0 @@ } |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
85672
2.51%2649
2.48%1
Infinity%