Dispatch

MongoDB Store

MongoDB store for document-oriented and horizontally-scalable Dispatch deployments.

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.

Usage

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))

Internals

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 Migrations

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 use

  • Document-oriented workloads where MongoDB is the primary data store.
  • Horizontally-scaled environments requiring sharding.
  • Teams already running MongoDB in their infrastructure.

On this page