This program listens to a MongoDB Change Stream, and publishes changes to Redis. It is designed to work with the cultofcoders:redis-oplog
Meteor package and meant as an alternative to oplogtoredis
with support for protectAgainstRaceConditions: false
.
redis-oplog
with the following configuration:
externalRedisPublisher: true
.globalRedisPrefix: "${database}."
, e.g., globalRedisPrefix: "meteor."
.changestream-to-redis
with the following environmental variables:
MONGO_URL
, e.g., mongodb://localhost:27017/meteor
.REDIS_URL
, e.g., redis://localhost:6379/1
.DEBUG
.
DEDUPLICATION
, e.g., 120
.
changestream-to-redis
listening to the same MongoDB database and pushing to the same Redis database.EXCLUDED_COLLECTIONS
, e.g., exports,logs
.
changestream-to-redis
and Redis load by ignoring write-intensive collections that don't require reactivity.FULL_DOCUMENT
.
oplogtoredis
.required
, updateLookup
, or whenAvailable
), and you can configure your collections to use protectAgainstRaceConditions: false
.FULL_DOCUMENT_COLLECTIONS
, e.g., notifications,users
.
FULL_DOCUMENT
flag.FULL_DOCUMENT
flag. Second will listen to other collections, fetching only their IDs.METRICS_ADDRESS
, e.g., 0.0.0.0:4000
.
changestream-to-redis
will expose Prometheus metrics at this address.REDIS_BATCH_SIZE
, default 1
.
REDIS_QUEUE_SIZE
, default 1024
.
changestream-to-redis
is meant to restart as soon as it exits.As reported on Meteor forums, after a couple of weeks in a pre-production environment and a week in a production one, the performance is significantly better than oplogtoredis
's:
Remember: your mileage may vary!
This is a standard Rust application: cargo fmt
will format the code, cargo clippy
will check it, and cargo test
will run tests.