Crate oplog [] [src]

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 Operations.

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

Oplog represents a MongoDB replica set oplog.

OplogBuilder

A builder for an Oplog.

Enums

Error

Error enumerates the list of possible error conditions when tailing an oplog.

Operation

A MongoDB oplog operation.

Type Definitions

Result

A type alias for convenience so we can fix the error to our own Error type.