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

Source
npmnpm
Version
2.1.0
Version published
Weekly downloads
0
-100%
Maintainers
3
Weekly downloads
 
Created
Source

Greenkeeper badge NSP Status

atrix-pubsub

Acoltatori based Pub/Sub intigraition into atrix microservice framework

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/facncy^*.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/fanzy/event', 
	//	payload: { an: 'event', with: { da: 'ta' } }
	// 	log: {<logger object>} 
	// }
	
	// publish anohter message
	await service.publish('other/event', { ... });
}

index.js

'use strict';

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

atrix.addService(new atrix.Service('pubsub', {
	// plugin configuration
	pubsub: {
		// setup redis connection
		redis: {
			host: 'localhost',
			port: 6379,
		},
		// select which broker to use. allowed: 'redis', 'in-memory' (default)
		broker: 'redis'
		
		// 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: { da: 'ta' } });

FAQs

Package last updated on 01 Feb 2018

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