Expand description
A library for iterating over a MongoDB replica set oplog.
Given a MongoDB Client
connected to a replica set, this crate allows you to iterate over an
Oplog
as if it were a collection of statically typed Operation
s.
§Example
At its most basic, an Oplog
will yield all operations in the oplog when iterated over:
use mongodb::{Client, ThreadedClient};
use oplog::Oplog;
let client = Client::connect("localhost", 27017).expect("Failed to connect to MongoDB.");
if let Ok(oplog) = Oplog::new(&client) {
for operation in oplog {
// Do something with operation...
}
}
Alternatively, an Oplog
can be built with a filter via OplogBuilder
to restrict the
operations yielded:
use mongodb::{Client, ThreadedClient};
use oplog::OplogBuilder;
let client = Client::connect("localhost", 27017).expect("Failed to connect to MongoDB.");
if let Ok(oplog) = OplogBuilder::new(&client).filter(Some(doc! { "op" => "i" })).build() {
for insert in oplog {
// Do something with insert operation...
}
}
Structs§
- Oplog represents a MongoDB replica set oplog.
- A builder for an
Oplog
.
Enums§
- Error enumerates the list of possible error conditions when tailing an oplog.
- A MongoDB oplog operation.
Type Aliases§
- A type alias for convenience so we can fix the error to our own
Error
type.