Agenda - v6.0.0
    Preparing search index...

    Interface AgendaBackend

    Unified backend interface for Agenda.

    A backend provides storage (required) and optionally notifications. This allows a single driver to implement both capabilities (e.g., PostgreSQL with LISTEN/NOTIFY) or just storage (e.g., MongoDB without notifications).

    Examples:

    • MongoBackend: provides repository only (polling-based)
    • PostgresBackend: provides repository + notificationChannel (LISTEN/NOTIFY)
    • Custom: mix storage from one system, notifications from another
    interface AgendaBackend {
        name: string;
        notificationChannel?: NotificationChannel;
        ownsConnection?: boolean;
        repository: JobRepository;
        connect(): Promise<void>;
        disconnect(): Promise<void>;
    }
    Index

    Properties

    name: string

    Human-readable name for this backend (e.g., 'MongoDB', 'PostgreSQL', 'Redis'). Used for display in dashboards and debugging.

    notificationChannel?: NotificationChannel

    Optional notification channel for real-time job notifications. If provided, Agenda will use this for immediate job processing. If not provided, Agenda falls back to periodic polling.

    ownsConnection?: boolean

    Whether the backend owns its database connection.

    • true: backend created the connection (e.g., from connection string)
    • false: connection was passed in by the user

    Used by agenda.stop() to determine whether to close the connection. Defaults to true if not implemented.

    repository: JobRepository

    The job repository for storage operations. This is required - every backend must provide storage.

    Methods

    • Connect to the backend. Called when agenda.start() is invoked. Should establish database connections, set up notification subscriptions, etc.

      Returns Promise<void>

    • Disconnect from the backend. Called when agenda.stop() is invoked. Should clean up connections, unsubscribe from notifications, etc.

      Returns Promise<void>