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

@studybear/message-queue-client

v2.0.0

Published

* Message Queue Client

Downloads

14

Readme

  • Message Queue Client

This package provides an easy way to communicate with a message queue using our messaging protocol.

** Getting started Clone the repository and run =npm install=.

** Running tests The package.json includes scripts to run all tests. Just run =npm test=!

** The protocol The messaging protocol is built directly on top of TCP and follows the simple syntax of = =. Available keywords are as follows:

*** =SCHED= Adds a new task to the queue. Messages need to follow the syntax

#+BEGIN_SRC text SCHED [@] #+END_SRC

The =@= is optional and defines which listening service should execute the task. If not supplied, the task will be added to a =default= queue.

**** Examples #+BEGIN_SRC text SCHED { email: "[email protected]", message: "test message" }@EMAILSERVICE #+END_SRC

Schedules a task for services listening to the =EMAILSERVICE= queue. The task is encoded as a JSON object and contains an email address and a message. The data part does not have to be JSON as we will see in the next example. In the context of the studybear backend however, we will always encode tasks as JSON objects.

#+BEGIN_SRC text SCHED test #+END_SRC

This is more of a minimum working example. Schedules the task "test" for services listing to the =default= queue.

*** =ASK= Asks for a task from the queue. The full syntax is

#+BEGIN_SRC text ASK [service] #+END_SRC

Again, the =service= parameter is optional and the =default= queue is accessed if omitted. Prompts the messaging queue to respond with a =WANT?= message.

**** Examples

#+BEGIN_SRC text ASK EMAILSERVICE #+END_SRC

Asks for a new task from the =EMAILSERVICE= queue.

#+BEGIN_SRC text ASK #+END_SRC

Asks for a new task from the =default= queue.

*** =WANT?= Sent by the messaging queue to supply a task to a service. The full syntax is

#+BEGIN_SRC text WANT? #+END_SRC

The data represents the task, and is equivalent to the data in the =SCHED= message.

**** Examples

#+BEGIN_SRC text WANT? { email: "[email protected]" message: "test message" } #+END_SRC

Returns the same task we scheduled in the =SCHED= section.

*** =NOPE= Sent by the messaging queue to indicate that there are no available tasks in the requested queue.

*** =ACK= Confirms the acceptance of a =WANT?= message. The messaging queue assumes that the task will be done successfully and will remove it from the relevant queue. Should the receiving service fail in fulfilling the task, it has to be re =SCHED= uled.

*** =DCL= Declines the task. The messaging queue will skip it and move it to the back of the queue. Can be used to postpone tasks. ATTENTION the messaging queue will not respond with another =WANT?= message, the client needs to =ASK= again.

*** =DEL= Removes the task from the messaging queue. This may be useful if the task data is corrupted or not readable for some other reason. To avoid blocking the queue with tasks that will be =DCL= ined anyway, services can use =DEL= to remove them.

*** =END= Ends the communication and closes the socket.