Socket
Book a DemoInstallSign in
Socket

@trigo/atrix-pubsub

Package Overview
Dependencies
Maintainers
3
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trigo/atrix-pubsub

Pubsub integration into atrix microservice framework

latest
Source
npmnpm
Version
4.0.2
Version published
Weekly downloads
2
Maintainers
3
Weekly downloads
 
Created
Source

Greenkeeper badge NSP Status

atrix-pubsub

** Redis based Pub/Sub integration into atrix microservice framework**

Compatibility

atrix-pubsub < 4.0.0 works with atrix < 6.0.0 atrix-pubsub >= 4.0.0 works with atrix >= 6.0.0

Features

  • Connection setup
  • filename based handler registrations

Installation

# install atrix
npm install -S @trigo/atrix

# install pubsub plugin
npm install -S @trigo/atrix-pubsub

Configuration

handlers/my/fancy^*.js

const Joi = require('joi');

module.exports.descrioption = 'my fancy event handler'
module.exports.schema = joi.object({ ... });
module.exports.handler = async (req, reply, service) => {
	console.log(req)
	// {
	//	path: 'my/fancy/event',
	//	payload: { an: 'event', with: { foo: 'bar' } }
	// 	log: {<logger object>}
	// }

	// publish another message
	await service.publish('other/event', { ... });
}

index.js

'use strict';

const atrix = require('@trigo/atrix');
const path = require('path');

atrix.addService({
	// name of the service
	name: 'pubsub', 
	// plugin configuration
	pubsub: {
		// setup redis connection
		redis: {
			host: 'localhost',
			port: 6379,
		},
		// select which broker to use. allowed: 'redis', 'in-memory' (default)
		broker: 'redis',
		brokerWildcard: '*', // topic path wildcard. allowed : '*', '%' (default and advised)

		// directory containing the handler files
		handlerDir: path.join(__dirname, './handlers'),
	},
});

// start service
await atrix.services.pubsub.start();

// publish message
await atrix.services.pubsub.publish('my/fancy/topic', { an: 'event', with: { foo: 'bar' } });

FAQs

Package last updated on 04 Jan 2019

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