Finish unified stack refactor.
Adds support for operation state, which will be used to pass authentication information around. Added generic backend that uses a channel to communicate with a typed backend.
parent: tbd commit: d15581c
1 | |
2 | |
3 | use Arc; |
4 | |
5 | use OperationError; |
6 | use Instance; |
7 | use ; |
8 | use ObjectBackend; |
9 | use GiteratedOperation; |
10 | use Repository; |
11 | use User; |
12 | use GiteratedBackend; |
13 | use ; |
14 | use Debug; |
15 | use Mutex; |
16 | |
17 | use crate; |
18 | |
19 | use |
20 | repository_commit_before, repository_diff, repository_file_from_id, repository_get_setting, |
21 | repository_get_value, repository_info, repository_set_setting, user_get_repositories, |
22 | user_get_setting, user_get_value, user_set_setting, |
23 | ; |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | async |
31 | &self, |
32 | _object: O, |
33 | _operation: &str, |
34 | _payload: D, |
35 | _operation_state: &StackOperationState, |
36 | |
37 | // We don't handle operations with this backend |
38 | Err |
39 | |
40 | |
41 | async |
42 | &self, |
43 | _object_str: &str, |
44 | _operation_state: &StackOperationState, |
45 | |
46 | Err |
47 | |
48 | |
49 | |
50 | /// A backend implementation which attempts to resolve data from the instance's database. |
51 | |
52 | |
53 | pub(self) our_instance: Instance, |
54 | pub(self) user_backend: , |
55 | pub(self) repository_backend: , |
56 | |
57 | |
58 | |
59 | |
60 | instance: Instance, |
61 | user_backend: , |
62 | repository_backend: , |
63 | |
64 | Self |
65 | our_instance: instance, |
66 | user_backend, |
67 | repository_backend, |
68 | |
69 | |
70 | |
71 | |
72 | let mut handlers = default; |
73 | |
74 | handlers |
75 | .insert |
76 | .insert |
77 | .insert |
78 | .insert |
79 | .insert |
80 | .insert |
81 | .insert |
82 | .insert |
83 | .insert |
84 | .insert |
85 | .insert |
86 | . |
87 | . |
88 | .; |
89 | |
90 | new |
91 | |
92 | |
93 | |
94 | |
95 | |
96 | f.debug_struct .finish |
97 | |
98 | |
99 | |
100 | // TODO: These should be on the stack |
101 | // These tests verify that the essential handling of the database backend is |
102 | // functional and correct. |
103 | |
104 | |
105 | use ; |
106 | |
107 | use Error; |
108 | |
109 | use UserAuthenticationToken; |
110 | |
111 | use |
112 | AuthenticationTokenRequest, Instance, RegisterAccountRequest, RepositoryCreateRequest, |
113 | ; |
114 | |
115 | use ObjectBackend; |
116 | |
117 | use |
118 | Commit, Description, Repository, RepositoryCommitBeforeRequest, RepositoryDiff, |
119 | RepositoryDiffRequest, RepositoryFile, RepositoryFileFromIdRequest, |
120 | RepositoryFileInspectRequest, RepositorySummary, RepositoryTreeEntry, |
121 | ; |
122 | use AnySetting; |
123 | use ; |
124 | use ; |
125 | use GiteratedBackend; |
126 | use StackOperationState; |
127 | use Value; |
128 | use Mutex; |
129 | |
130 | use crate; |
131 | |
132 | use DatabaseBackend; |
133 | ; |
134 | |
135 | |
136 | |
137 | async |
138 | assert_eq!; |
139 | |
140 | Ok |
141 | & to_vec .unwrap, |
142 | |
143 | .unwrap |
144 | |
145 | async |
146 | Ok |
147 | & to_vec .unwrap, |
148 | |
149 | .unwrap |
150 | |
151 | async |
152 | &mut self, |
153 | _user: &User, |
154 | _name: &str, |
155 | _setting: &Value, |
156 | |
157 | Ok |
158 | |
159 | async |
160 | Ok |
161 | |
162 | async |
163 | &mut self, |
164 | _requester: , |
165 | _user: &User, |
166 | |
167 | todo! |
168 | |
169 | |
170 | |
171 | |
172 | |
173 | async |
174 | &mut self, |
175 | _request: RegisterAccountRequest, |
176 | |
177 | todo! |
178 | |
179 | |
180 | async |
181 | &mut self, |
182 | _source: &Instance, |
183 | _request: AuthenticationTokenRequest, |
184 | |
185 | todo! |
186 | |
187 | |
188 | |
189 | ; |
190 | |
191 | |
192 | |
193 | async |
194 | &mut self, |
195 | _user: &User, |
196 | _request: &RepositoryCreateRequest, |
197 | |
198 | todo! |
199 | |
200 | async |
201 | &mut self, |
202 | _requester: , |
203 | _repository: &Repository, |
204 | _request: &RepositoryFileInspectRequest, |
205 | |
206 | todo! |
207 | |
208 | async |
209 | &mut self, |
210 | _requester: , |
211 | _repository: &Repository, |
212 | _request: &RepositoryFileFromIdRequest, |
213 | |
214 | todo! |
215 | |
216 | async |
217 | &mut self, |
218 | _requester: , |
219 | _repository: &Repository, |
220 | _request: &RepositoryDiffRequest, |
221 | |
222 | todo! |
223 | |
224 | async |
225 | &mut self, |
226 | _requester: , |
227 | _repository: &Repository, |
228 | _request: &RepositoryCommitBeforeRequest, |
229 | |
230 | todo! |
231 | |
232 | async |
233 | &mut self, |
234 | _repository: &Repository, |
235 | _name: &str, |
236 | |
237 | Ok |
238 | & to_vec .unwrap, |
239 | |
240 | .unwrap |
241 | |
242 | async |
243 | &mut self, |
244 | _repository: &Repository, |
245 | _name: &str, |
246 | |
247 | Ok |
248 | & to_vec .unwrap, |
249 | |
250 | .unwrap |
251 | |
252 | async |
253 | &mut self, |
254 | _repository: &Repository, |
255 | _name: &str, |
256 | _setting: &Value, |
257 | |
258 | Ok |
259 | |
260 | |
261 | async |
262 | // Ok(true) |
263 | Ok |
264 | == & from_str |
265 | "test_user:test.giterated.dev/[email protected]", |
266 | |
267 | .unwrap |
268 | |
269 | |
270 | |
271 | |
272 | DatabaseBackend |
273 | our_instance: from_str .unwrap, |
274 | user_backend: new as _, |
275 | repository_backend: new as _, |
276 | |
277 | .into_backend |
278 | |
279 | |
280 | |
281 | todo! |
282 | |
283 | |
284 | |
285 | async |
286 | let backend = test_backend; |
287 | let operation_state = operation_state; |
288 | |
289 | let mut user = backend |
290 | . |
291 | .await |
292 | .expect; |
293 | |
294 | user. |
295 | .await |
296 | .expect; |
297 | |
298 | |
299 | |
300 | async |
301 | let backend = test_backend; |
302 | let operation_state = operation_state; |
303 | |
304 | let mut user = backend |
305 | . |
306 | .await |
307 | .expect; |
308 | |
309 | user. |
310 | .await |
311 | .expect; |
312 | |
313 | |
314 | |
315 | async |
316 | let backend = test_backend; |
317 | let operation_state = operation_state; |
318 | |
319 | let mut user = backend |
320 | . |
321 | .await |
322 | .expect; |
323 | |
324 | user. |
325 | .await |
326 | .expect; |
327 | |
328 | |
329 | |
330 | async |
331 | let backend = test_backend; |
332 | let operation_state = operation_state; |
333 | |
334 | let mut repository = backend |
335 | . |
336 | "test_user:test.giterated.dev/[email protected]", |
337 | &operation_state, |
338 | |
339 | .await |
340 | .expect; |
341 | |
342 | repository |
343 | . |
344 | .await |
345 | .expect; |
346 | |
347 | |
348 | |
349 | async |
350 | let backend = test_backend; |
351 | let operation_state = operation_state; |
352 | |
353 | let mut repository = backend |
354 | . |
355 | "test_user:test.giterated.dev/[email protected]", |
356 | &operation_state, |
357 | |
358 | .await |
359 | .expect; |
360 | |
361 | repository |
362 | . |
363 | .await |
364 | .expect; |
365 | |
366 | |
367 | |
368 | async |
369 | let backend = test_backend; |
370 | let operation_state = operation_state; |
371 | |
372 | let mut repository = backend |
373 | . |
374 | "test_user:test.giterated.dev/[email protected]", |
375 | &operation_state, |
376 | |
377 | .await |
378 | .expect; |
379 | |
380 | repository |
381 | . |
382 | .await |
383 | .expect; |
384 | |
385 | |
386 |