mrcond

Crates.iomrcond
lib.rsmrcond
version0.1.0
created_at2025-06-20 23:19:47.618222+00
updated_at2025-06-20 23:19:47.618222+00
descriptionMongoDB to RabbitMQ connector daemon - CLI tool for streaming MongoDB change events to RabbitMQ
homepage
repositoryhttps://github.com/f-squirrel/mrcond
max_upload_size
id1720363
size138,967
Dmitry (f-squirrel)

documentation

README

mrcond

A production-ready CLI daemon for streaming MongoDB change events to RabbitMQ, built on the mrcon library.

Features

  • Streams MongoDB change events to RabbitMQ with robust, resumable delivery.
  • Supervises jobs for each collection with automatic restart and retry logic.
  • Configurable via YAML, environment variables, and CLI.
  • Structured logging and tracing (configurable via env vars).
  • Healthcheck endpoint at /health (returns HTTP 200 OK).
  • Docker-ready for containerized deployment and integration testing.

Usage

Build and run the daemon with your configuration:

cargo build --release
./target/release/mrcond --config config.yaml --prefix MYAPP

Or use Docker Compose for local integration testing:

make run

Command-Line Options

MongoDB-RabbitMQ Connector Daemon

Usage: mrcond [OPTIONS]

Options:
  -c, --config <CONFIG>  Path to config file (YAML) [default: /app/config.yaml]
  -p, --prefix <PREFIX>  Prefix for environment variables [default: MRCON]
  -h, --help             Print help
  -V, --version          Print version

Configuration

MongoDB collection and rabbitmq stream settings config file

Example:

collections:
  - watched:
      db_name: "test"
      coll_name: "testcoll"
      change_stream_pre_and_post_images: false
    resume_tokens:
      tokens_db_name: "test"
      tokens_coll_name: "resume_tokens"
      tokens_coll_capped: true
      tokens_coll_size_in_bytes: 1048576
    rabbitmq:
      stream_name: "testqueue"
  • collections: List of collections to watch and forward to RabbitMQ.
    • watched: MongoDB collection to watch.
      • db_name: Database name.
      • coll_name: Collection name.
      • change_stream_pre_and_post_images: Enable pre/post images (bool).
    • resume_tokens: Where to store resume tokens for reliable streaming.
      • tokens_db_name: Database for tokens.
      • tokens_coll_name: Collection for tokens.
      • tokens_coll_capped: Use capped collection (bool).
      • tokens_coll_size_in_bytes: Size for capped collection.
    • rabbitmq: Target RabbitMQ queue/stream.
      • stream_name: Queue/stream name.

Environment Variables

You can set MongoDB and RabbitMQ connection strings, as well as log level, using environment variables with the configured prefix (default: MRCON).

Examples:

# Set MongoDB connection string
MRCON_CONNECTIONS__MONGO_URI=mongodb://localhost:27017

# Set RabbitMQ connection string
MRCON_CONNECTIONS__RABBITMQ_URI=amqp://guest:guest@localhost:5672/

# Set log level (info, debug, warn, etc.)
MRCON_LOG=info
  • The prefix is set by --prefix (default: MRCON).

Health check

A health endpoint is available at http://localhost:3000/health and returns HTTP 200 OK.

License

Licensed under the MIT License. See the main repository for details.

Commit count: 0

cargo fmt