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.
- 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.
npm install @workehub/pipeline
import { Pipeline } from "@workehub/pipeline";
// Create an instance of Pipeline with a local storage path
const pipeline = new Pipeline({ local: "./data" });
Attach a pipeline with options
pipeline.attach("pipelineName", { pollInterval: 1000 });
pipeline.listen("pipelineName", async (message) => {
// Process the message
console.log("Received message:", message);
});
await pipeline.add("pipelineName", "Your message here");
await pipeline.add("pipelineName", { email: "bob@email" }); // Automatic conversion to string (JSON)
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>