Skip to main content

Built and signed on GitHub Actions

An ActivityPub/fediverse server framework

This package works with Node.js, Deno, Bun
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
100%
Published
a week ago (1.3.0)
class ParallelMessageQueue
implements MessageQueue

A message queue that processes messages in parallel. It takes another MessageQueue, and processes messages in parallel up to a certain number of workers.

Actually, it's rather a decorator than a queue itself.

Note that the workers do not run in truly parallel, in the sense that they are not running in separate threads or processes. They are running in the same process, but are scheduled to run in parallel. Hence, this is useful for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's workloads.

Constructors

new
ParallelMessageQueue(
queue: MessageQueue,
workers: number,
)

Constructs a new ParallelMessageQueue with the given queue and number of workers.

Properties

Methods

enqueue(
message: any,
): Promise<void>
listen(
handler: (message: any) => Promise<void> | void,
): Promise<void>

Add Package

deno add jsr:@fedify/fedify

Import symbol

import { ParallelMessageQueue } from "@fedify/fedify/federation";

---- OR ----

Import directly with a jsr specifier

import { ParallelMessageQueue } from "jsr:@fedify/fedify/federation";

Add Package

npx jsr add @fedify/fedify

Import symbol

import { ParallelMessageQueue } from "@fedify/fedify/federation";

Add Package

yarn dlx jsr add @fedify/fedify

Import symbol

import { ParallelMessageQueue } from "@fedify/fedify/federation";

Add Package

pnpm dlx jsr add @fedify/fedify

Import symbol

import { ParallelMessageQueue } from "@fedify/fedify/federation";

Add Package

bunx jsr add @fedify/fedify

Import symbol

import { ParallelMessageQueue } from "@fedify/fedify/federation";