1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
//!
//! rustque is a fast local on disk data que, it can que Vec<u8> and can be best customized to your hardware.
//!
//! rustque works on a principal of assembly lines passing on flume messeges to diffrent worker modules, when you initiate rustque it results into the first message pass in the assembly line this que handler can be cloned for async writes to the que on disk level depending on the os and hardware features disk writes are async too, disk files are distributed into empty and filled sections on a new que entry one disk worker locks a empty space and writes to it this locking mechnism allows us to spawn multiple disk workers which can read and write from the same file simultaniously.
//!
//!
//! sample code
//! ```
//! use rustque::{Que,Config};
//!
//! #[tokio::main]
//! async fn main(){
//!
//! //---------------------------
//! //initiate que
//! //---------------------------
//! let mut que:Que;
//! match Que::new(Config::new(
//! vec![
//! "D://workstation/expo/rust/rust_store/test/rustque/que1.rustque".to_string(),
//! "D://workstation/expo/rust/rust_store/test/rustque/que2.rustque".to_string(),
//! "D://workstation/expo/rust/rust_store/test/rustque/que3.rustque".to_string()
//! ], //que files
//! 500000000, //min que size on disk in bytes
//! 5000000, //expand file on disk by this many bytes when full in bytes
//! 100 //no of disk workers per que file
//! )).await{
//! Ok(v)=>{
//! que = v;
//! println!("que initiated : {:?}",hold.elapsed());
//! },
//! Err(e)=>{
//! println!("!!! failed-que::new => {:?}",e);
//! return;
//! }
//! }
//!
//! //---------------------------
//! //write items to the que
//! //---------------------------
//! if true {
//! match que.add(vec![1,2,3]).await{
//! Ok(mut que_response)=>{
//! collect.push(async move{
//! que_response.check().await
//! });
//! },
//! Err(_e)=>{
//! println!("!!! failed-que-add : {:?}",_e);
//! }
//! }
//! }
//!
//! //---------------------------
//! // please enable get, remove and reset
//! // functions once at a time or write
//! // que items for each of them
//! //---------------------------
//!
//! //---------------------------
//! //get qued item from que
//! //---------------------------
//! if true{
//! match que.next().await{
//! Ok(mut next_response)=>{
//! let _quer_resp = next_response.check().await;
//! if !_quer_resp {break;}
//! match next_response.data().await{
//! Some((value,pointer))=>{
//! println!("value : {:?}",value);
//! },
//! None=>{}
//! }
//! },
//! Err(_e)=>{
//! println!("!!! failed-que-get : {:?}",_e);
//! }
//! }
//! }
//!
//! //---------------------------
//! //remove item from que
//! //---------------------------
//! if true{
//! match que.next().await{
//! Ok(mut next_response)=>{
//! if next_response.check().await {
//! match next_response.data().await{
//! Some((_value,pointer))=>{
//! match que.remove(pointer).await{
//! Ok(mut remove_response)=>{
//! let remove_resp = remove_response.check().await;
//! println!("remove resp : {:?}",remove_resp);
//! },
//! Err(_e)=>{
//! println!("!!! failed-que-remove : {:?}",_e);
//! }
//! }
//! },
//! None=>{}
//! }
//! }
//! },
//! Err(_e)=>{
//! println!("!!! failed-que-get : {:?}",_e);
//! }
//! }
//! }
//!
//! //---------------------------
//! //reset item in que
//! //---------------------------
//! if true{
//! match que.next().await{
//! Ok(mut next_response)=>{
//! if next_response.check().await {
//! match next_response.data().await{
//! Some((_value,pointer))=>{
//! match que.reset(pointer).await{
//! Ok(mut reset_response)=>{
//! let reset_resp = reset_response.check().await;
//! println!("reset resp : {:?}",reset_resp);
//! },
//! Err(_e)=>{
//! println!("!!! failed-que-reset : {:?}",_e);
//! }
//! }
//! },
//! None=>{}
//! }
//! }
//! },
//! Err(_e)=>{
//! println!("!!! failed-que-get : {:?}",_e);
//! }
//! }
//! }
//!
//! }
//! ```
//! Bechmarking is a feature that needs to be enabled in cargo.toml this features provides tools to bechmark best settings for your hardware you need to provide multiple settings to test from and results will be written on the file you specify.
//!
//! ```
//! [dependencies]
//! //enable bechmark feature in cargo.toml
//! rustque = {version="1.0.4", features=["benchmark"]}
//! ```
//!
//! ```
//! use rustque::bechmark::{BenchmarkBuilder,Benchmark};
//!
//! #[tokio::main]
//! async fn main(){
//!
//! //---------------------------
//! //init benchmark builder
//! //---------------------------
//! let mut build = BenchmarkBuilder::new(
//! "D://workstation/expo/rust/rust_store/test/rustque/bechmark_8.txt".to_string()
//! );
//!
//! //---------------------------
//! //add a benchmark
//! //---------------------------
//! build.add(Benchmark{
//! no_of_writers:10,
//! no_of_writes:5000,
//! map_files:vec![
//! "D://workstation/expo/rust/rust_store/test/rustque/que1.rustque".to_string(),
//! "D://workstation/expo/rust/rust_store/test/rustque/que2.rustque".to_string(),
//! "D://workstation/expo/rust/rust_store/test/rustque/que3.rustque".to_string(),
//! ],
//! write_size:256,
//! min_que_size:10000000,
//! expansion_size:5000000,
//! no_of_disk_workers:10
//! });
//!
//! //---------------------------
//! //run the benchmarks
//! //---------------------------
//! build.run().await;
//!
//! }
//! ```
mod io;
mod config;
mod que;
mod map;
mod disk;
mod workers;
mod locator;
mod response;
#[cfg(feature = "benchmark")]
pub mod benchmark;
pub use config::Config;
pub use que::Que;
pub use workers::Pointer;