Crate optra [] [src]

An engine for keeping remote siles synchronized.

The engine is based on the Admissabilty Based Sequence Transformation algorithm (doi: 10.1109/TPDS.2010.64) The idea is that each site that wants to have a file synchronized will have an instance of Engine running. Any changes that are made to teh file should be run through the engine using either process_diffs() or process_transaction() prior to being broadcast. Any changes that are made at a remote site should be run through the engine using integrate_remote() prior to being applied to the file.

This crate generally works well with rdiff, but can work with any system that generates difference operations that are limited to insert and delete.

Examples

Assuming you have a method read_transaction for reading transactions from remote sites, the process for integrating remote changes onto a local file go like this:

 use optra::{Engine, TransactionSequence, TimeStamper};
 use std::collections::{LinkedList, BTreeMap};
 use std::fs::OpenOptions;
 // Assume we already have an engine up and running
 let (mut remote_sequence, remote_lookup) = read_transaction();
 engine.integrate_remote(&mut remote_sequence, &remote_lookup, &mut time_stamper);
 let mut file = OpenOptions::new()
                .read(true)
                .write(true)
                .open("local_file")
                .unwrap();
 remote_sequence.apply(&mut file).unwrap();

On the other hand, if you have a Diff generated by detecting differences to a local file, you can process the diff and then send it out (assuming you have a method called send_transaction())

In order to ensure that your tranaction has appropriate timestamps, you must have a TimeStamper to keep track of the sequencing of operations.

 let diffs = file_hashes.diff_and_update(File::open("local_file").unwrap()).unwrap();
 let (transaction, lookup) = engine.process_diffs(diffs, &mut time_stamper);
 send_transaction(transaction, lookup);

Structs

DeleteOperation

Represents an operation which removes data from a file

Engine

Process file change operations in such a way that they can be synchronized across sites

InsertOperation

Represents an operation which inserts data into a file

OTError

Represents an error in attempting to synchronize remote operations

TimeStamper

Tracks the relationship between local timestamps and the timestamp on remote machines.

TransactionSequence

Represents a sequence of transactions that can be performed on a file.

Enums

ErrorKind

Represents the kind of error we encountered synchronizing operations

Traits

Operation

An operation that will make a change to a file.