1use serde::{Deserialize, Serialize};
2use simple_wal::LogError;
3use std::{io::Error, time::Duration};
4
5pub mod database;
6pub mod document;
7mod index;
8pub mod persistent_worker;
9mod router;
10pub mod schema;
11pub mod storage;
12pub mod storage_redis;
13pub mod storage_vector;
14mod storage_vector_test;
15pub mod vector;
16pub mod wal;
17
18pub use async_trait::async_trait;
19
20pub static TIMEOUT: Duration = Duration::from_secs(5);
21
22pub use storage::{Event, RQuery};
23
24#[allow(dead_code)]
25#[derive(Debug)]
26pub enum Status {
27 SenderNotFound,
28 SendersRepetive,
29}
30
31#[derive(Debug)]
32pub enum StatusResult {
33 LogErr(LogError),
34 IoError(Error),
35 End,
36 ReporterIsOff,
37 Err(String),
38 Duplicate,
39}
40
41impl ToString for StatusResult {
42 fn to_string(&self) -> String {
43 match self {
44 StatusResult::LogErr(e) => e.to_string(),
45 StatusResult::IoError(e) => e.to_string(),
46 StatusResult::End => "End".to_string(),
47 StatusResult::ReporterIsOff => "ReporterIsOff".to_string(),
48 StatusResult::Err(e) => e.to_string(),
49 StatusResult::Duplicate => "Duplicate".to_string(),
50 }
51 }
52}
53
54#[derive(Debug)]
55pub enum SessionResult {
56 Closed,
57 Timeout,
58 Full,
59 NoResponse,
60 DataStoreNotFound,
61 UnImplement,
62 Err(StatusResult),
63}
64
65impl ToString for SessionResult {
66 fn to_string(&self) -> String {
67 match self {
68 SessionResult::Closed => "Closed".to_string(),
69 SessionResult::Timeout => "Timeout".to_string(),
70 SessionResult::Full => "Full".to_string(),
71 SessionResult::NoResponse => "NoResponse".to_string(),
72 SessionResult::DataStoreNotFound => "DataStoreNotFound".to_string(),
73 SessionResult::UnImplement => "UnImplement".to_string(),
74 SessionResult::Err(e) => e.to_string(),
75 }
76 }
77}
78
79#[allow(dead_code)]
80pub enum WorkerState {
81 Continue,
82 Disconnected,
83 Empty,
84}
85
86#[derive(Clone, Serialize, Deserialize)]
87pub enum StorageType {
88 RamCopies,
90
91 DiskCopies,
93}
94
95
96#[derive(Clone, Serialize, Deserialize)]
97pub struct Options<'a> {
98 pub path: &'a str,
99 pub storage_name: &'a str,
100 pub total_page_size: usize,
101 pub stype: StorageType,
102 pub off_reporter: bool,
103}
104
105impl<'a> Options<'a> {
106 pub fn new(
107 path: &'a str,
108 storage_name: &'a str,
109 total_page_size: usize,
110 stype: StorageType,
111 off_reporter: bool,
112 ) -> Self {
113 Options {
114 path,
115 storage_name,
116 total_page_size,
117 stype,
118 off_reporter,
119 }
120 }
121}
122
123impl<'a> Into<Config> for Options<'a> {
124 fn into(self) -> Config {
125 Config {
126 path: self.path.to_owned(),
127 storage_name: self.storage_name.to_owned(),
128 total_page_size: self.total_page_size.to_owned(),
129 stype: self.stype.to_owned(),
130 off_reporter: self.off_reporter.to_owned(),
131 }
132 }
133}
134
135
136#[derive(Clone, Serialize, Deserialize)]
137pub struct Config {
138 pub path: String,
139 pub storage_name: String,
140 pub total_page_size: usize,
141 pub stype: StorageType,
142 pub off_reporter: bool,
143}
144
145impl Config {
146 pub fn new(
147 path: String,
148 storage_name: String,
149 total_page_size: usize,
150 stype: StorageType,
151 off_reporter: bool,
152 ) -> Self {
153 Config {
154 path,
155 storage_name,
156 total_page_size,
157 stype,
158 off_reporter,
159 }
160 }
161
162
163}