Skip to content
/ oplog Public
forked from mudge/oplog

A Rust library for iterating over a MongoDB replica set oplog.

License

Notifications You must be signed in to change notification settings

lookback/oplog

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oplog

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 futures::StreamExt;
use mongodb::Client;
use oplog::Oplog;

let client = Client::with_uri_str("mongodb://localhost").await?;

let mut oplog = Oplog::new(&client).await?;

while let Some(res) = oplog.next().await {
    let oper = res?;
    println!("{:?}", oper);
}

Alternatively, an Oplog can be built with a filter via OplogBuilder to restrict the operations yielded:

use futures::StreamExt;
use mongodb::bson::doc;
use mongodb::Client;
use oplog::Oplog;
use std::process;

let client = Client::with_uri_str("mongodb://localhost").await?;

let mut oplog = Oplog::builder()
    .filter(Some(doc! { "op": "i" }))
    .build(&client)
    .await?;

while let Some(res) = oplog.next().await {
    let oper = res?;
    println!("{:?}", oper);
}

License: MIT

About

A Rust library for iterating over a MongoDB replica set oplog.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%