Skip to main content

Built and signed on GitHub Actions

Works with
This package works with Node.js, Deno, BunIt is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score88%
License
MIT
Downloads4/wk
Publisheda week ago (2.2.0)

MySQL/MariaDB drivers for Fedify

Classes

c
MysqlKvStore(
pool: MysqlPool,
options?: MysqlKvStoreOptions
)

A key-value store that uses MySQL (or MariaDB) as the underlying storage.

  • cas(
    key: KvKey,
    expectedValue: unknown,
    newValue: unknown,
    options?: KvStoreSetOptions
    ): Promise<boolean>

    {@inheritDoc KvStore.cas}

  • delete(key: KvKey): Promise<void>

    {@inheritDoc KvStore.delete}

  • drop(): Promise<void>

    Drops the table used by the key-value store. Does nothing if the table does not exist. Resets the initialized flag so that MysqlKvStore.initialize can recreate the table on the next call.

  • get<T = unknown>(key: KvKey): Promise<T | undefined>

    {@inheritDoc KvStore.get}

  • initialize(): Promise<void>

    Creates the table used by the key-value store if it does not already exist. Does nothing if the table already exists.

  • list(prefix?: KvKey): AsyncIterable<KvStoreListEntry>

    {@inheritDoc KvStore.list}

  • set(
    key: KvKey,
    value: unknown,
    options?: KvStoreSetOptions | undefined
    ): Promise<void>

    {@inheritDoc KvStore.set}

c
MysqlMessageQueue(
pool: MysqlPool,
options?: MysqlMessageQueueOptions
)

A message queue that uses MySQL or MariaDB as the underlying storage. Messages are delivered via periodic polling, since MySQL and MariaDB do not provide a LISTEN/NOTIFY equivalent.

  • drop(): Promise<void>

    Drops the message queue table if it exists. Resets the initialized flag so that MysqlMessageQueue.initialize can recreate the table on the next call.

  • enqueue(
    message: any,
    options?: MessageQueueEnqueueOptions
    ): Promise<void>

    {@inheritDoc MessageQueue.enqueue}

  • enqueueMany(
    messages: readonly any[],
    options?: MessageQueueEnqueueOptions
    ): Promise<void>

    {@inheritDoc MessageQueue.enqueueMany}

  • initialize(): Promise<void>

    Initializes the message queue table if it does not already exist. Concurrent calls are coalesced — only one initialization runs at a time.

  • listen(
    handler: (message: any) => void | Promise<void>,
    options?: MessageQueueListenOptions
    ): Promise<void>

    {@inheritDoc MessageQueue.listen}

  • nativeRetrial: boolean

    MySQL/MariaDB does not provide native retry mechanisms; Fedify handles retries itself.

Interfaces

I

Options for the MySQL key-value store.

  • The probability (between 0 and 1, inclusive) that expired entries are cleaned up on each mutation. Defaults to 1 (always clean up). Set to 0 to disable automatic expiry cleanup entirely.

  • initialized: boolean

    Whether the table has been initialized. false by default.

  • tableName: string

    The table name to use for the key-value store. "fedify_kv" by default.

I

Options for the MySQL message queue.

  • handlerTimeout: Temporal.Duration | Temporal.DurationLike

    The maximum time to wait for a message handler to complete before the queue moves on. This is a soft timeout: when a handler exceeds the limit, the queue stops waiting and logs a timeout error, but it cannot cancel the handler itself — the handler's promise continues running in the background. In the ordered-key path the advisory lock is always released in a finally block, so a timed-out handler will not permanently block the same ordering key. However, concurrent side-effects from the still-running handler may interleave with the next handler for the same key; callers should be aware of this.

  • initialized: boolean

    Whether the table has been initialized. false by default.

  • pollInterval: Temporal.Duration | Temporal.DurationLike

    The poll interval for the message queue. 1 second by default.

  • tableName: string

    The table name to use for the message queue. "fedify_mq" by default.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@fedify/mysql

Import symbol

import * as mod from "@fedify/mysql";
or

Import directly with a jsr specifier

import * as mod from "jsr:@fedify/mysql";