Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rewaa/event-broker

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rewaa/event-broker

A broker for all the events that Rewaa will ever produce or consume

  • 3.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27K
increased by40.48%
Maintainers
1
Weekly downloads
 
Created
Source

event-broker

A broker for all the events that Rewaa will ever produce or consume.

This package is intended to abstract out the functionality of an event broker keeping the underlying client hidden.

Currently the underlying client is SQS. Under the hood, this broker maps events to queues on SQS. Multiple events may belong to a single queue. A queue can only be consumed by one type of consumer. This means that currently Fan-out is not supported. To send the same type of events, multiple queues would be required.

Usage

const eventTopics: IEventTopicMap = {
	["SEND_NOTIFICATION"]: {
		name:  "NOTIFICATION",
		isConsuming:  true,
		isFifo:  false,
	},
	["SEND_NOTIFICATION_FIFO"]: {
		name:  "NOTIFICATION_FIFO",
		isConsuming:  true, //will consume this topic
		isFifo:  true,
		visibilityTimeout:  10
	}
}

const emitterOptions: = {
	emitterType:  EmitterType.SQS,
	environment:  `local`,
	eventTopicMap:  eventTopics,
	localEmitter:  new  EventEmitter(),
	useExternalBroker: true,
	isConsumer:  true, //If consuming events
	deadLetterQueueEnabled:  true
};

const emitter = new Emitter(emitterOptions);

emitter.on<{payload: ISendNotificationPayload}>("SEND_NOTIFICATION", async (...data) => {
	//Process event
});

await  emitter.initialize(emitterOptions);

Consuming topics yourself

If you are consuming the topics/queues yourself, but want event-broker to handle the routing logic, you can use the processMessage function like so:

await emitter.processMessage<EmitterType.SQS>(message, topicUrl);

Keywords

FAQs

Package last updated on 20 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc