arangors_graph_exporter/
config.rs1#[derive(Clone, Debug)]
2pub struct DatabaseConfiguration {
3 pub database: String,
4 pub endpoints: Vec<String>,
5 pub username: String,
6 pub password: String,
7 pub jwt_token: String,
8 pub tls_cert: Option<String>,
9}
10
11impl Default for DatabaseConfiguration {
12 fn default() -> Self {
13 DatabaseConfigurationBuilder::new().build()
14 }
15}
16
17pub struct DatabaseConfigurationBuilder {
18 database: Option<String>,
19 endpoints: Option<Vec<String>>,
20 username: Option<String>,
21 password: Option<String>,
22 jwt_token: Option<String>,
23 tls_cert: Option<String>,
24}
25
26impl Default for DatabaseConfigurationBuilder {
27 fn default() -> Self {
28 Self::new()
29 }
30}
31
32impl DatabaseConfigurationBuilder {
33 pub fn new() -> Self {
34 DatabaseConfigurationBuilder {
35 database: None,
36 endpoints: None,
37 username: None,
38 password: None,
39 jwt_token: None,
40 tls_cert: None,
41 }
42 }
43
44 pub fn database(mut self, database: String) -> Self {
45 self.database = Some(database);
46 self
47 }
48
49 pub fn endpoints(mut self, endpoints: Vec<String>) -> Self {
50 self.endpoints = Some(endpoints);
51 self
52 }
53
54 pub fn username(mut self, username: String) -> Self {
55 self.username = Some(username);
56 self
57 }
58
59 pub fn password(mut self, password: String) -> Self {
60 self.password = Some(password);
61 self
62 }
63
64 pub fn jwt_token(mut self, jwt_token: String) -> Self {
65 self.jwt_token = Some(jwt_token);
66 self
67 }
68
69 pub fn tls_cert(mut self, tls_cert: String) -> Self {
70 self.tls_cert = Some(tls_cert);
71 self
72 }
73
74 pub fn build(self) -> DatabaseConfiguration {
75 DatabaseConfiguration {
76 database: self.database.unwrap_or_else(|| "_system".to_string()),
77 endpoints: self
78 .endpoints
79 .unwrap_or_else(|| vec!["http://localhost:8529".to_string()]),
80 username: self.username.unwrap_or_else(|| "root".to_string()),
81 password: self.password.unwrap_or_default(),
82 jwt_token: self.jwt_token.unwrap_or_default(),
83 tls_cert: self.tls_cert,
84 }
85 }
86}
87
88#[derive(Clone, Debug)]
89pub struct DataLoadConfiguration {
90 pub parallelism: u32,
91 pub batch_size: u64,
92 pub prefetch_count: u32,
93 pub load_all_vertex_attributes: bool,
94 pub load_all_edge_attributes: bool,
95}
96
97impl Default for DataLoadConfiguration {
98 fn default() -> Self {
99 DataLoadConfigurationBuilder::new().build()
100 }
101}
102
103impl DataLoadConfiguration {
104 pub fn new(
105 parallelism: Option<u32>,
106 batch_size: Option<u64>,
107 prefetch_count: Option<u32>,
108 load_all_vertex_attributes: bool,
109 load_all_edge_attributes: bool,
110 ) -> Self {
111 DataLoadConfiguration {
112 parallelism: parallelism.unwrap_or(8),
113 batch_size: batch_size.unwrap_or(100_000),
114 prefetch_count: prefetch_count.unwrap_or(5),
115 load_all_vertex_attributes,
116 load_all_edge_attributes,
117 }
118 }
119}
120
121pub struct DataLoadConfigurationBuilder {
122 parallelism: Option<u32>,
123 batch_size: Option<u64>,
124 prefetch_count: Option<u32>,
125 load_all_vertex_attributes: bool,
126 load_all_edge_attributes: bool,
127}
128
129impl Default for DataLoadConfigurationBuilder {
130 fn default() -> Self {
131 Self::new()
132 }
133}
134
135impl DataLoadConfigurationBuilder {
136 pub fn new() -> Self {
137 DataLoadConfigurationBuilder {
138 parallelism: None,
139 batch_size: None,
140 prefetch_count: None,
141 load_all_vertex_attributes: false,
142 load_all_edge_attributes: false,
143 }
144 }
145
146 pub fn parallelism(mut self, parallelism: u32) -> Self {
147 self.parallelism = Some(parallelism);
148 self
149 }
150
151 pub fn batch_size(mut self, batch_size: u64) -> Self {
152 self.batch_size = Some(batch_size);
153 self
154 }
155
156 pub fn prefetch_count(mut self, prefetch_count: u32) -> Self {
157 self.prefetch_count = Some(prefetch_count);
158 self
159 }
160
161 pub fn load_all_vertex_attributes(mut self, load_all_vertex_attributes: bool) -> Self {
162 self.load_all_vertex_attributes = load_all_vertex_attributes;
163 self
164 }
165
166 pub fn load_all_edge_attributes(mut self, load_all_edge_attributes: bool) -> Self {
167 self.load_all_edge_attributes = load_all_edge_attributes;
168 self
169 }
170
171 pub fn build(self) -> DataLoadConfiguration {
172 DataLoadConfiguration::new(
173 self.parallelism,
174 self.batch_size,
175 self.prefetch_count,
176 self.load_all_vertex_attributes,
177 self.load_all_edge_attributes,
178 )
179 }
180}