ecpool

Crates.io: ecpool Documentation Build Status License: MIT

This crate provides thread pool ([ErasureCoderPool]) for managing executions of erasure coding.

Documentation

ecpool also provides [ErasureCode] trait defines erasure coding interface and of which implemtations can be executed via [ErasureCoderPool].

There are some built-in implementations of the trait: - [LibErasureCoder]: - This implementation uses [liberasurecode] crate that is a wrapper for [openstack/liberasurecode] library. - It is highly optimized and stable but only available in Unix environments. - [ReplicaCoder]: - This implementation simply replicates the input data. - It is provided for example and testing purposes only and not intended to use in production.

Build Prerequisites

It is required to install [openstack/liberasurecode] and its dependencies by executing the following commands before building this crate:

console $ git clone https://github.com/frugalos/liberasurecode $ cd liberasurecode && sudo ./install_deps.sh

Examples

Basic usage: ```rust use ecpool::replica::ReplicaCoder; use ecpool::{ErrorKind, ErasureCoderPool}; use std::num::NonZeroUsize; use std::result::Result; use trackable::error::{Failure, Failed};

// Creates a pool let datafragments = NonZeroUsize::new(4).okorelse(|| Failure::from(Failed))?; let parityfragments = NonZeroUsize::new(2).okorelse(|| Failure::from(Failed))?; let coder = ErasureCoderPool::new(ReplicaCoder::new(datafragments, parityfragments));

// Encodes let data = vec![0, 1, 2, 3]; let encoded = fibers_global::execute(coder.encode(data.clone()))?;

// Decodes asserteq!( Some(&data), fibersglobal::execute(coder.decode(encoded[0..].tovec())) .asref() .ok() ); asserteq!( Some(&data), fibersglobal::execute(coder.decode(encoded[1..].tovec())) .asref() .ok() ); asserteq!( Some(&data), fibersglobal::execute(coder.decode(encoded[2..].tovec())) .asref() .ok() ); asserteq!( Err(ErrorKind::InvalidInput), fibersglobal::execute(coder.decode(encoded[3..].tovec())).maperr(|e| *e.kind()) ); ```