Giter Site home page Giter Site logo

oplog's Introduction

Oplog Build Status

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

Current version: 0.3.0
Supported Rust versions: 1.14

Install

Install Oplog by adding the following to your Cargo.toml:

oplog = "0.3.0"

Usage

#[macro_use]
extern crate bson;
extern crate mongodb;
extern crate oplog;

use mongodb::{Client, ThreadedClient};
use oplog::{Operation, Oplog, OplogBuilder};

fn main() {
    let client = Client::connect("localhost", 27017).expect("Failed to connect to MongoDB.");

    if let Ok(oplog) = Oplog::new(&client) {
        for operation in oplog {
            match operation {
                Operation::Noop { timestamp, .. } => println!("No-op at {}", timestamp),
                Operation::Insert { timestamp, .. } => println!("Insert at {}", timestamp),
                Operation::Update { timestamp, .. } => println!("Update at {}", timestamp),
                Operation::Delete { timestamp, .. } => println!("Delete at {}", timestamp),
                Operation::Command { timestamp, .. } => println!("Command at {}", timestamp),
                Operation::ApplyOps { timestamp, .. } => println!("ApplyOps at {}", timestamp),
            }
        }
    }

    // Or, if you want to filter out certain operations:

    if let Ok(oplog) = OplogBuilder::new(&client).filter(Some(doc! { "op" => "i" })).build() {
        for insert in oplog {
            println!("{}", insert);
        }
    }
}

Documentation

Full API documentation is available at http://mudge.name/oplog

References

And many thanks to Ryman for his help along the way.

License

Copyright © 2016-2018 Paul Mucur.

Distributed under the MIT License.

oplog's People

Contributors

mudge avatar canndrew avatar

Stargazers

Kiệt Thành Võ avatar zach avatar 寧靜 avatar messense avatar Jeff Mealo avatar Gabriel Castro avatar Dean Karn avatar

Watchers

James Cloos avatar Jeff Mealo avatar  avatar

oplog's Issues

Future of this crate

Hi!

Thanks for writing this crate. I wonder what your plans are for it?

I would like to use it in a project, so I spent some time to modernize it. See commit here: lookback@bc97080

I'm up for any way we can modernize this on crates.io:

  • I provide PR with updates, you release.
  • I can be added as a maintainer here and/or crates.io.
  • Transfer repo if you want to be rid of it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.