1.2.1 • Published 10 months ago

adonis-pubsub v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

adonis-pubsub

PubSub provider for AdonisJS

npm-image license-image typescript-image

PubSub provider for AdonisJS

Supported brokers:

  • MQTT
  • Google PubSub
  • Redis

Installation

npm install --save adonis-pubsub

Configuration:

node ace configure adonis-pubsub

Per driver configuration

  • MQTT configuration

npm install --save async-mqtt
  • Google PubSub configuration

npm install --save @google-cloud/pubsub
  • Redis configuration

Please configure @adonisjs/redis (docs) package and set the appropriate redis connection name in config/pubsub.ts

Usage

import Event from '@ioc:Adonis/Core/Event'
import Logger from '@ioc:Adonis/Core/Logger'
import PubSub from '@ioc:Romch007/PubSub'

// Subscribe to topic and listen for message
PubSub.subscribe('example')
Event.on('pubsub:message', ({ topic, message }) => {
  Logger.info(`Message from ${topic}: ${message.toString()}`)
})

// Publish message to topic
await PubSub.publish('example', Buffer.from('message data'))
1.2.0

10 months ago

1.2.1

10 months ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago