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

async-client

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-client

NodeJS library to send or receive async messages (independently of the technology (redis, activemq))

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Publish / Subscribe Client (Support to generators)

Now only support to Redis. In the future we'll add support to amqp protocol.

Install

npm install --save https://github.com/Vizzuality/async-client-nodejs.git

Use

You have examples in examples folder. To execute example: node example/redis.js

Code:

'use strict';
const CHANNEL = 'myChannel';

function* iter(number) {
    for (var i = 0; i < number; i++) {
        yield i;
    }
}

function* gen(number) {
    for (var val of iter(number)) {
        console.log(val);
    }
}

var AsyncClient = require('../index');

var asyncClientPublish = new AsyncClient(AsyncClient.REDIS, {
    host: 'localhost' // redis url
});
var asyncClientSubscriber = new AsyncClient(AsyncClient.REDIS, {
    host: 'localhost'// redis url
});

var channelSubscribe = asyncClientSubscriber.toChannel(CHANNEL);
channelSubscribe.on('message', function*(channel, message) {
    console.log('Message received: ' + message);
    yield gen(message);
    console.log('Message completed');
});
channelSubscribe.subscribe();

asyncClientPublish.toChannel(CHANNEL).emit(2);
asyncClientPublish.toChannel(CHANNEL).emit(5);

FAQs

Package last updated on 30 Jul 2016

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