Skip to content

Commit

Permalink
docs: Introduce @fedify/amqp
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Oct 14, 2024
1 parent cd97ded commit 9642125
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/manual/federation.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ runtime).
As separate packages, [@fedify/redis] provides [`RedisMessageQueue`] class,
which is a Redis-backed implementation for production use,
and [@fedify/postgres] provides [`PostgresMessageQueue`] class, which is a
PostgreSQL-backed implementation for production use.
PostgreSQL-backed implementation for production use, and [@fedify/amqp] provides
[`AmqpMessageQueue`] class, which is an AMQP broker-backed implementation for
production use.

Further details are explained in the [*Message queue* section](./mq.md).

Expand All @@ -116,6 +118,8 @@ Further details are explained in the [*Message queue* section](./mq.md).
[`RedisMessageQueue`]: https://jsr.io/@fedify/redis/doc/mq/~/RedisMessageQueue
[`PostgresMessageQueue`]: https://jsr.io/@fedify/postgres/doc/mq/~/PostgresMessageQueue
[@fedify/amqp]: https://github.com/dahlia/fedify-amqp
[`AmqpMessageQueue`]: https://jsr.io/@fedify/amqp/doc/mq/~/AmqpMessageQueue

### `manuallyStartQueue`

Expand Down
45 changes: 45 additions & 0 deletions docs/manual/mq.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,51 @@ const federation = createFederation<void>({
[`LISTEN`]: https://www.postgresql.org/docs/current/sql-listen.html
[`NOTIFY`]: https://www.postgresql.org/docs/current/sql-notify.html

### `AmqpMessageQueue`

> [!NOTE]
> The [`AmqpMessageQueue`] class is available in the [@fedify/amqp] package.
> [!NOTE]
>
> Although it's theoretically possible to be used with any AMQP 0-9-1 broker,
> [`AmqpMessageQueue`] is primarily designed for and tested with [RabbitMQ].
[`AmqpMessageQueue`] is a message queue implementation that uses AMQP 0-9-1
for message delivery. The best-known AMQP broker is [RabbitMQ]. It provides
scalability and high performance, making it suitable for production use across
various runtimes. It requires an AMQP broker setup and management.

Best for
: Production use across various runtimes.

Pros
: Persistent, reliable, scalable, supports multiple workers.

Cons
: Requires AMQP broker setup and management.

~~~~ typescript twoslash
import type { KvStore } from "@fedify/fedify";
// ---cut-before---
import { createFederation } from "@fedify/fedify";
import { AmqpMessageQueue } from "@fedify/amqp";
import { connect } from "amqplib";

const federation = createFederation({
// ---cut-start---
kv: null as unknown as KvStore,
// ---cut-end---
queue: new AmqpMessageQueue(await connect("amqp://localhost")), // [!code highlight]
// ... other options
});
~~~~

*[AMQP]: Advanced Message Queuing Protocol
[`AmqpMessageQueue`]: https://jsr.io/@fedify/amqp/doc/mq/~/AmqpMessageQueue
[@fedify/amqp]: https://github.com/dahlia/fedify-amqp
[RabbitMQ]: https://www.rabbitmq.com/


Implementing a custom `MessageQueue`
------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"devDependencies": {
"@braintree/sanitize-url": "^7.1.0",
"@deno/kv": "^0.8.2",
"@fedify/amqp": "0.1.0-dev.8",
"@fedify/fedify": "1.1.0-dev.432",
"@fedify/postgres": "0.1.0-dev.2",
"@fedify/redis": "0.2.0-dev.10",
Expand All @@ -9,9 +11,12 @@
"@logtape/logtape": "^0.5.1",
"@shikijs/vitepress-twoslash": "^1.17.6",
"@teidesu/deno-types": "^1.46.3",
"@types/amqplib": "^0.10.5",
"@types/better-sqlite3": "^7.6.11",
"@types/bun": "^1.1.9",
"amqplib": "^0.10.4",
"cli-progress": "^3.12.0",
"dayjs": "^1.11.13",
"hono": "^4.6.1",
"ioredis": "^5.4.1",
"markdown-it-abbr": "^2.0.0",
Expand Down
Loading

0 comments on commit 9642125

Please sign in to comment.