Skip to content

Instantly share code, notes, and snippets.

@htimur
Created October 4, 2018 19:01
Show Gist options
  • Save htimur/ed7de2f3d4306744912f9973ced15099 to your computer and use it in GitHub Desktop.
Save htimur/ed7de2f3d4306744912f9973ced15099 to your computer and use it in GitHub Desktop.
MongoDB Shard oplog tailing source creation
val shardOplogSources: Seq[Source[Document, NotUsed]] = shardService.getShards.map { shard =>
RestartSource.withBackoff(
minBackoff = 3.seconds,
maxBackoff = 30.seconds,
randomFactor = 0.2, // adds 20% "noise" to vary the intervals slightly
maxRestarts = 20 // limits the amount of restarts to 20
) { () =>
oplog.source(MongoClient(shard.uri))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment