npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

virtdb-connector

v3.0.34

Published

Module for connecting a node.js component to the VirtDB system

Downloads

28

Readme

Build Status

virtdb-connector

Module for connecting node.js based modules to VirtDB.

Usage

npm install virtdb-connector

    zmq = require 'zmq'
    VirtDBConnector = require 'virtdb-connector'
    Const = VirtDBConnector.Constants
    proto_meta = (require 'virtdb-proto').meta_data

    processMessages = (data) -> # do something great with messages arrived

    VirtDBConnector.connect(@name, connectionString)
    VirtDBConnector.setupEndpoint (onBound) ->
        socket = zmq.socket Const.ZMQ_REP
        socket.on "message", (request) ->
            try
                data = proto_meta.parse request, "virtdb.interface.pb.MetaDataRequest"
                processMessages data
            catch ex
                log.error "Error happened in message receiver: ", V_(ex)
                socket.send "err"
        socket.bind VirtDBConnector.getConnectionString(), onBound socket, Const.META_DATA, Const.ZMQ_REP

Documentation

connect (name, connectionString, callback)

Connects to the VirtDB system.   
  • name: the name of component. This name has to be unique throughout a VirtDB installation.
  • connectionString: the ZeroMQ connection string of the Endpoint service socket of the Config Service component.
  • callback(err): A callback that is called when connection is finished.

getIP()

Returns the own IP address of the current component.

onAddress(service_type, connection_type, callback)

Calls the given callback when an endpoint with the requested service_type and connection_type is published from the Endpoint Service.  
  • service_type: Possible values: QUERY, COLUMN, META_DATA, DB_CONFIG, DB_CONFIG_QUERY, LOG_RECORD, GET_LOGS, CONFIG, ENDPOINT, IP_DISCOVERY, OTHER, *
  • connection_type: Possible values: REQ_REP, PUSH_PULL, PUB_SUB, RAW_UDP
  • callback: function callback(endpoint_name, address, service_type, connection_type) Where address and connection_type are not always set. Null address means endpoint is deleted.

setupEndpoint(protocol_call)

Set up an endpoint. An endpoint is a service with a given service_type and connection_type that other componenets can connect to. For a possible set of service/connection pairs see the [virtdb-proto](https://github.com/starschema/virtdb-proto) project.
  • protocol_call: function protocol_call(onBound)
    • onBound: function onBound(socket, svcType, zmqType) Callback that has to be called when the ZeroMQ endpoint is set up. It reports the created endpoint to the VirtDB Endpoint Service so that other components get to know about this new endpoint.

subscribe(service_type, callback [, channel])

 Subscribe for messages of a given type.
  • service_type: What types of messages to subscribe for.
  • callback: function callback(channel, message) Called when messages arrive on the given subscription.
  • channel: Channel ID to subscribe for. If not set all messages are passed to the callback.

makeConfigurable(template, callback)

Makes the component configurable through the VirtDB config protocol. For a detailed protocol description see the [virtdb-proto](https://github.com/starschema/virtdb-proto) project.
  • template: The configuration options of the component.
  • callback: function callback(config) Called when configuration messages arrive.

sendRequest(name, service_type, message, callback)

Sends a message to the endpoint with the given name and svcType on a ZMQ REQ socket. When the reply arrives the given callback is called. The parsing and serialization of the message with Google Protocol Buffers is the responsibility of the caller.
  • name: The name of the component to send the message to.
  • service_type: The VirtDB endpoint type of the channel of the component to send the message to.
  • message: A message serialized with Protocol Buffers to send to the given endpoint.
  • callback(err, reply): The callback hat is called on errors or when received the response.

replyServer(messageHandler, options, callback)

DEPRECATED

Sets up a server that can accept requests on a ZMQ REP socket.
  • messageHandler(id, message, sendMethod): The callback is called every time a message arrives on the socket and gives the message as the first argument and a send function as the second. (sendMethod(err, id, reply): The reply is the message that is to be sent back on the socket.)
  • options: Possible options are:
    • url (required): The url of the endpoint that the endpoint should be listening on. Example format is: tcp://*:12345. Both the IP and the Port part can be ephemeral.
    • timeout (default: 3000): As for REQ-REP ZMQ sockets every request has to be replied and if the messageHandler does not call the provided send method in time an empty reply is being sent.
    • checkInterval (default: 500): In millisecs how often the timeout is checked.
    • emptyMessage (default: ''): The message that is to be sent when the send method is not called in time.
  • callback(err, address): A callback that is called when an error happens during the setup or the server is set up and listening.

routerServer(messageHandler, options, callback)

Sets up a server that can accept requests on a ZMQ ROUTER socket.
  • messageHandler(id, message, sendMethod): The callback is called every time a message arrives on the socket and gives the message as the first argument and a send function as the second. (sendMethod(err, id, reply): The reply is the message that is to be sent back on the socket.)
  • options: Possible options are:
    • url (required): The url of the endpoint that the endpoint should be listening on. Example format is: tcp://*:12345. Both the IP and the Port part can be ephemeral.
    • timeout (default: 3000): As for REQ-REP ZMQ sockets every request has to be replied and if the messageHandler does not call the provided send method in time an empty reply is being sent.
    • checkInterval (default: 500): In millisecs how often the timeout is checked.
    • emptyMessage (default: ''): The message that is to be sent when the send method is not called in time.
  • callback(err, address): A callback that is called when an error happens during the setup or the server is set up and listening.

More info at: http://www.virtdb.com