@workehub/pipeline
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Pipeline

Pipeline is a powerful library designed for event processing and message queue management. It offers robust features for efficiently handling events and managing message flow within your application.

With Pipeline, you can easily register events, customize event configurations, and process messages in a controlled and efficient manner. Whether you're dealing with high event volumes or aiming for reliable message processing, Pipeline provides the necessary tools to streamline your event-driven workflows.

Please note that Pipeline is currently in active development and refinement, with ongoing updates and improvements.

Features

  • Efficient event processing and message queuing for optimized performance.
  • Asynchronous message handling for concurrent processing of messages.
  • Convenient event registration and callback functionality for seamless event management.
  • Flexible persistence options, with support for LMDB storage. Future updates may include additional storage options for expanded capabilities.

Installation

npm install @workehub/pipeline

Usage

import { Pipeline } from "@workehub/pipeline";

// Create an instance of Pipeline with a local storage path
const pipeline = new Pipeline({ local: "./data" });

Register an event with a configuration

Attach a pipeline with options

pipeline.attach("pipelineName", { pollInterval: 1000 });

Register an event callback

pipeline.listen("pipelineName", async (message) => {
  // Process the message
  console.log("Received message:", message);
});

Add a message to the pipeline

await pipeline.add("pipelineName", "Your message here");
await pipeline.add("pipelineName", { email: "bob@email" }); // Automatic conversion to string (JSON)

API

The constructor of the Pipeline class accepts a configuration parameter, which should include the local storage path for the LMDB database.

Pipeline(config: PipelineConfig)

Attaches a pipeline to the Pipeline instance with the specified name and options.

attach(name: string, options: PipelineOpts): void

Defines a callback function to be executed when a message is processed for the specified pipeline.

listen(name: string, callback: (message: PipelineMessage) => Promise<void>): void

Adds a message to the end of the message queue for the specified pipeline.

add(name: string, value: string): Promise<void>

Package Sidebar

Install

npm i @workehub/pipeline

Weekly Downloads

9

Version

1.0.3

License

ISC

Unpacked Size

32.2 kB

Total Files

8

Last publish

Collaborators

  • isacrdev