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

pulsar-node

v1.0.2

Published

Node event based pulsar

Downloads

11

Readme

pulsar-node

NPM

Node binding for Apache Pulsar

Pulsar logo

This library is inspired by pulsar-client-node

Requirements

pulsar-client is a peer dependency, make sure to install it. Tested on pulsar-client 1.0.0-rc.1

 npm install pulsar-client

Install

 npm install pulsar-node

Options

  • serviceUrl : required

  • binding

  • operationTimeoutSeconds

  • ioThreads

  • messageListenerThreads

  • concurrentLookupRequest

  • useTls

  • tlsTrustCertsFilePath

  • tlsValidateHostname

  • tlsAllowInsecureConnection

  • statsIntervalInSeconds

  • auth : optional

    • tls : {Object}
    • athenz : {Object}
    • token : string

authentication

tls

Pulsar.init({
  serviceUrl: 'pulsar+ssl://localhost:6651',
  tlsTrustCertsFilePath: '/path/to/server.crt',
  auth : {
    tls : {
      certificatePath: '/path/to/client.crt',
      privateKeyPath: '/path/to/client.key'
    }
  }
});

token

Pulsar.init({
  serviceUrl: 'pulsar://localhost:6650',
  auth : {
    token : 'a.b.c'
  }
});

API

init

Pulsar.init({
  serviceUrl : 'pulsar://localhost:6650'
}).then( pulsar =>{
  // ready to use
}, error =>{
  // something wrong happen
});

send(<message>)

Message format

  • topic : required
  • message : required
  • encoding : default 'binary', options ['binary', 'string']
  • producerName
  • sendTimeoutMs
  • initialSequenceId
  • maxPendingMessages
  • maxPendingMessagesAcrossPartitions
  • blockIfQueueFull
  • messageRoutingMode
  • hashingScheme
  • compressionType
  • batchingEnabled
  • batchingMaxPublishDelayMs
  • batchingMaxMessages
  • properties
pulsar.send({
  topic   : 'persistent://public/default/my-topic',
  message : 'hello world'
}).then( seccess => {
  // Message was sent
}, error => {
  // Something wrong happen
});

addConsumer(<TopicName>, <Options>)

TopicName

  • TopicName : required

Options

  • subscription : required
  • subscriptionType
  • ackTimeoutMs
  • receiverQueueSize
  • receiverQueueSizeAcrossPartitions
  • consumerName
  • properties
let consumer = pulsar.addConsumer('persistent://public/default/my-topic', { subscription : 'sub1' });

consumer.on('message', message => {

  console.log('The message data', {
    id           : message.getMessageId().toString(),
    topicName    : message.getTopicName(),
    properties   : message.getProperties(),
    data         : message.getData().toString(),
    partitionKey : message.getPartitionKey(),
  });

  consumer.acknowledge(message);
});

consumer.on('error', error =>{
  // Something wrong happen
});

Message Object

Methods

  • getTopicName
  • getProperties
  • getData
  • getMessageId
  • getPublishTimestamp
  • getEventTimestamp
  • getPartitionKey
  • validateCMessage

close

this mechanisms closes all consumers, producers, and client.

pulsar.close().then( closed =>{
  // all is closed
}, error =>{
  // Something wrong happen
});