Home

Awesome

nsq-nodes

Build Status Build Status NPM version

Nsq helper to poll a nsqlookupd service for all it's nodes and mirror it locally.

NPM

INFO: all examples are written in coffee-script

Install

  npm install nsq-nodes

Initialize

new NsqNodes( config );

Example:

var NsqNodes = require( "nsq-nodes" )

var nodes = new NsqNodes({
    // Listen to two local nsq lookupservers
    "lookupdHTTPAddresses": [ "127.0.0.1:4161", "127.0.0.1:4163" ]
});

// get the current list of nodes
nodes.list( function( err, nodes ){
    if( err ){
        // handle the error
    }
    console.log( nodes ) // -> an array of nodes. E.g.: ( )`users`, `logins`, ... )


    // listen for new nodes
    nodes.on( "add", function( node ){
        // called until a new node arrived
    });

    // listen for removed nodes
    nodes.on( "remove", function( node ){
        // called until a node was removed
    });

    // listen for node list changes
    nodes.on( "change", function( nodeList ){
        // beside the `add` and `remove` events a single "change" event will be emitted
    });

    // listen for errors
    nodes.on( "error", function( err ){
        // E.g. called if a invalid filter was used or no lookup server is available
    });

});

Config

Methods

.activate()

Activate the module

Return

( Boolean ): true if it is now activated. false if it was already active

.deactivate()

Deactivate the module

Return

( Boolean ): true if it is now deactivated. false if it was already inactive

.active()

Test if the module is currently active

Return

( Boolean ): Is active?

.list( cb )

Get a list of the current nodes

Return

( Self ): The instance itself for chaining.

Example:

nodes.list( function( err, nodes ){
    if( err ){
        // handle the error
    }
    console.log( nodes ) // -> an array of nodes. E.g.: ( )`users`, `logins`, ... )
});

Events

add

A new node was added

Arguments

Example:

nodes.on( "add", function( node ){
    // called until a new node arrived
});

remove

A existing node was removed

Arguments

Example:

nodes.on( "remove", function( node ){
    // called until a node was removed
});

change

The list of nodes changed

Arguments

Example:

nodes.on( "change", function( nodeList ){
    // beside the `add` and `remove` events a single "change" event will be emitted
});

error

An error occurred. E.g. called if a invalid filter was used or no lookup server is available

Arguments

Example:

nodes.on( "error", function( err ){
    // handle the error
});

ready

Emitted once the list of nodes where received the first time. This is just an internal helper. The Method list will also wait for the first response. The events add, remove and change are active after this first response. Example:

nodes.on( "ready", function( err ){
    // handle the error
});

Release History

VersionDateDescription
1.1.02019-01-25now able to handle the formats of nsq < and > 1.x
1.0.02019-01-25updated nodes response handler to match nsq >= 1.x format
0.0.32016-05-04Another configuration bugfix
0.0.22016-05-04Bugfix configuration and update to lodash
0.0.12015-11-27Initial commit

NPM

Initially Generated with generator-mpnodemodule

Other projects

NameDescription
nsq-loggerNsq service to read messages from all topics listed within a list of nsqlookupd services.
nsq-topicsNsq helper to poll a nsqlookupd service for all it's topics and mirror it locally.
nsq-watchWatch one or many topics for unprocessed messages.
node-cacheSimple and fast NodeJS internal caching. Node internal in memory cache like memcached.
rsmqA really simple message queue based on redis
redis-heartbeatPulse a heartbeat to redis. This can be used to detach or attach servers to nginx or similar problems.
systemhealthNode module to run simple custom checks for your machine or it's connections. It will use redis-heartbeat to send the current state to redis.
rsmq-clia terminal client for rsmq
rest-rsmqREST interface for.
redis-sessionsAn advanced session store for NodeJS and Redis
connect-redis-sessionsA connect or express middleware to simply use the redis sessions. With redis sessions you can handle multiple sessions per user_id.
redis-notificationsA redis based notification engine. It implements the rsmq-worker to safely create notifications and recurring reports.
hyperrequestA wrapper around hyperquest to handle the results
task-queue-workerA powerful tool for background processing of tasks that are run by making standard http requests
soyerSoyer is small lib for server side use of Google Closure Templates with node.js.
grunt-soy-compileCompile Goggle Closure Templates ( SOY ) templates including the handling of XLIFF language files.
backlunrA solution to bring Backbone Collections together with the browser fulltext search engine Lunr.js
domelA simple dom helper if you want to get rid of jQuery
obj-schemaSimple module to validate an object by a predefined schema

The MIT License (MIT)

Copyright © 2015 M. Peter, http://www.tcs.de

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.