Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frugalos/ecpool
A Rust crate that provides thread pool for managing executions of erasure coding
https://github.com/frugalos/ecpool
erasure-coding rust thread-pool
Last synced: about 2 months ago
JSON representation
A Rust crate that provides thread pool for managing executions of erasure coding
- Host: GitHub
- URL: https://github.com/frugalos/ecpool
- Owner: frugalos
- License: mit
- Created: 2018-09-27T06:16:01.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-16T04:37:38.000Z (over 3 years ago)
- Last Synced: 2024-10-06T14:07:27.165Z (3 months ago)
- Topics: erasure-coding, rust, thread-pool
- Language: Rust
- Size: 24.4 KB
- Stars: 14
- Watchers: 7
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
ecpool
======[![Crates.io: ecpool](https://img.shields.io/crates/v/ecpool.svg)](https://crates.io/crates/ecpool)
[![Documentation](https://docs.rs/ecpool/badge.svg)](https://docs.rs/ecpool)
[![Build Status](https://travis-ci.org/frugalos/ecpool.svg?branch=master)](https://travis-ci.org/frugalos/ecpool)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)This crate provides thread pool ([`ErasureCoderPool`]) for managing executions of erasure coding.
[Documentation](https://docs.rs/ecpool)
`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 data_fragments = NonZeroUsize::new(4).ok_or_else(|| Failure::from(Failed))?;
let parity_fragments = NonZeroUsize::new(2).ok_or_else(|| Failure::from(Failed))?;
let coder = ErasureCoderPool::new(ReplicaCoder::new(data_fragments, parity_fragments));// Encodes
let data = vec![0, 1, 2, 3];
let encoded = fibers_global::execute(coder.encode(data.clone()))?;// Decodes
assert_eq!(
Some(&data),
fibers_global::execute(coder.decode(encoded[0..].to_vec()))
.as_ref()
.ok()
);
assert_eq!(
Some(&data),
fibers_global::execute(coder.decode(encoded[1..].to_vec()))
.as_ref()
.ok()
);
assert_eq!(
Some(&data),
fibers_global::execute(coder.decode(encoded[2..].to_vec()))
.as_ref()
.ok()
);
assert_eq!(
Err(ErrorKind::InvalidInput),
fibers_global::execute(coder.decode(encoded[3..].to_vec())).map_err(|e| *e.kind())
);
```[`ErasureCoderPool`]: https://docs.rs/ecpool/0.1/struct.ErasureCoderPool.html
[`ErasureCode`]: https://docs.rs/ecpool/0.1/trait.ErasureCode.html
[`liberasurecode`]: https://github.com/frugalos/liberasurecode
[openstack/liberasurecode]: https://github.com/openstack/liberasurecode
[`LibErasureCoder`]: https://docs.rs/ecpool/0.1/liberasurecode/struct.LibErasureCoder.html
[`ReplicaCoder`]: https://docs.rs/ecpool/0.1/replica/struct.ReplicaCoder.html