tulip / oplogtoredis

Publish MongoDB oplog entries to Redis
Apache License 2.0
38 stars 9 forks source link

High Availability mode #12

Closed benweissmann closed 6 years ago

benweissmann commented 6 years ago

Right now, we publish everything we read from the oplog to a Redis channel. This means that if you're running two copies of oplogtoredis, you'll end up with duplicate messages send to redis.

Instead, we could do something like:

ok := SET <unique id from oplog> true NX EX <expiration>
if ok {
  // message was not already published
  PUBLISH <channel> <msg>
}

Which would use Redis to de-duplicate messages based on the unique ID assigned to all oplog operations.

This gives us a couple nice advantages:

benweissmann commented 6 years ago

Fixed in ffccb1f3ca85fb9f552d6217aa6a7fc0a63b448e