From 1089cf85a74887430d5d21c42886a4a05bac2be9 Mon Sep 17 00:00:00 2001 From: Determinant Date: Tue, 16 Jun 2020 16:03:37 -0400 Subject: add readme --- README.rst | 11 +++++++++++ src/lib.rs | 19 +++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 README.rst diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..f63eea1 --- /dev/null +++ b/README.rst @@ -0,0 +1,11 @@ +growth-ring +=========== + +.. image:: https://travis-ci.com/ava-labs/growth-ring.svg?token=EbLxqxy3qxjHrZKkyoP4&branch=master + :target: https://travis-ci.com/Determinant/growth-ring + +Documentation +------------- +- Latest_ + +.. _Latest: https://docs.rs/growth-ring/0.1.0/growthring/ diff --git a/src/lib.rs b/src/lib.rs index 6e3109d..61aeb72 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,17 +5,17 @@ //! ``` //! use growthring::{WALStoreAIO, wal::WALLoader}; //! use futures::executor::block_on; -//! // start from empty WAL (trucate = true) +//! // Start with empty WAL (truncate = true). //! let store = WALStoreAIO::new("./walfiles", true, |_, _| {Ok(())}); //! let mut wal = WALLoader::new(9, 8, 1000).recover(store).unwrap(); -//! // write a vector of records to WAL +//! // Write a vector of records to WAL. //! for f in wal.grow(vec!["record1(foo)", "record2(bar)", "record3(foobar)"]).into_iter() { //! let ring_id = block_on(f).unwrap().1; //! println!("WAL recorded record to {:?}", ring_id); //! } //! //! -//! // load from WAL if exists (trucate = false) +//! // Load from WAL (truncate = false). //! let store = WALStoreAIO::new("./walfiles", false, |payload, ringid| { //! // redo the operations in your application //! println!("recover(payload={}, ringid={:?})", @@ -24,22 +24,21 @@ //! Ok(()) //! }); //! let mut wal = WALLoader::new(9, 8, 1000).recover(store).unwrap(); -//! // We'll see the playback of the log even if there is no failure. Let's remove the old log -//! // entries by assuming they are already persistent in your application. +//! // We saw some log playback, even there is no failure. +//! // Let's try to grow the WAL to create many files. //! let ring_ids = wal.grow((0..100).into_iter().map(|i| "a".repeat(i)).collect::>()) //! .into_iter().map(|f| block_on(f).unwrap().1).collect::>(); -//! -//! -//! // Let's assume all these records are not longer needed. There will only be one remaining file -//! // in ./walfiles +//! // Then assume all these records are not longer needed. We can tell WALWriter by the `peel` +//! // method. //! block_on(wal.peel(ring_ids)).unwrap(); +//! // There will only be one remaining file in ./walfiles. //! //! let store = WALStoreAIO::new("./walfiles", false, |payload, _| { //! println!("payload.len() = {}", payload.len()); //! Ok(()) //! }); //! let wal = WALLoader::new(9, 8, 1000).recover(store).unwrap(); -//! // The ./walfiles is empty now as all records are played back. +//! // After each recovery, the ./walfiles is empty. //! ``` #[macro_use] extern crate scan_fmt; -- cgit v1.2.3-70-g09d2