Skip to content

LeanKit-Labs/rabbit-topology

Repository files navigation

rabbit-topology

NPM Version Build Coverage

Initial release designed to generate a topology definition.
Other libraries are used to assert the topology against a running server.

Produce a rabbit topology definition from a DSL.

Domain-Specific Language

TODO: Formally define the DSL

Examples

Publisher

const definition = {
	exchanges: {
		"app.events": {
			type: "fanout",
			exchanges: {
				"app.events.topic": {
					type: "topic"
				}
			}
		}
	}
}

Subscriber

const definition = {
	exchanges: {
		"app.service": {
			type: "fanout",
			queues: {
				inbound: {
					name: "app.service.queue",
					durable: true,
					prefetch: 50,
					deadLetterExchange: {
						name: "app.service.dlx",
						type: "fanout",
						queues: {
							"ingress.dlq": { durable: true }
						}
					}
				}
			},
			subscriptions: {
				"app.events.topic": {
					type: "topic",
					patterns: [ "app.#" ]
				}
			}
		}
	}
};
const topology = parser.parse( definition );
console.log( topology.queues.inbound );  // "app.service.queue"