Dispatch
1.x
Docs/Dispatch/MongoDB Store
Open

Reading1 min
Updated31 Jul 2026
Sourcev1/stores/mongo.mdx

The store/mongo package implements Dispatch's store interfaces using the grove ORM with the MongoDB driver. Jobs, workflows, cron entries, and events are stored as documents, making it a natural fit for deployments that already run MongoDB.

Usage01

import (
    "github.com/xraph/grove"
    "github.com/xraph/grove/drivers/mongodriver"
    "github.com/xraph/dispatch/store/mongo"
)

db, err := grove.Open(mongodriver.Open("mongodb://localhost:27017", "dispatch"))
if err != nil {
    log.Fatal(err)
}

s := mongo.New(db)
if err := s.Migrate(ctx); err != nil {
    log.Fatal(err)
}

d, err := dispatch.New(dispatch.WithStore(s))

Internals02

AspectDetail
Drivergrove ORM + mongodriver
MigrationsGrove migrations with JSON Schema validation + indexes
TransactionsMongoDB sessions (replica-set required for multi-doc txns)
Collectionsdispatch_jobs, dispatch_workflow_runs, dispatch_checkpoints, dispatch_cron_entries, dispatch_dlq, dispatch_events, dispatch_workers
CloseNo-op -- caller owns the *grove.DB lifecycle

Grove Migrations03

The store exports a Migrations group for use with Grove's migration orchestrator. This enables tracked, versioned migrations across all stores in your application:

import mongostore "github.com/xraph/dispatch/store/mongo"

// mongostore.Migrations is a migrate.Group for the dispatch mongo store.
// Register it with the grove migration orchestrator for coordinated migrations.

When to use04

  • Document-oriented workloads where MongoDB is the primary data store.

  • Horizontally-scaled environments requiring sharding.

  • Teams already running MongoDB in their infrastructure.