Beginning of `stack-next` refactor
-Refactoring the protocol stack into something similar to a runtime. -Handles merging handler builders which is placing the ground work for plugins in. - Increased metadata generation during compilation enables less ser/de during execution. - Goal is to have an O(1) time from incoming operation to calling handlers. - Decreased penalty for using the statically typed API from within your code, now avoids some allocation. # Changes - Added `GiteratedRuntime` which is to replace the current unified stack - Added `RuntimeBuilder` which does what the current `OperationHandlers` struct does, but much better. - Added `RuntimeMetadata` to store type metadata for new `Any` based internals - Refactored serde_json out of the internal operation handling
parent: tbd commit: 708dea4
1 | |
2 | |
3 | |
4 | use Arc; |
5 | |
6 | use OperationError; |
7 | use Instance; |
8 | use ; |
9 | use ObjectBackend; |
10 | use GiteratedOperation; |
11 | use ; |
12 | use ; |
13 | use GiteratedBackend; |
14 | use ; |
15 | use Debug; |
16 | use Mutex; |
17 | |
18 | use crate; |
19 | |
20 | use |
21 | instance_authentication_request, instance_create_repository_request, |
22 | instance_registration_request, repository_commit_before, repository_diff, |
23 | repository_diff_patch, repository_file_from_id, repository_file_from_path, |
24 | repository_get_setting, repository_get_value, repository_get_value_description, |
25 | repository_get_value_visibility, repository_info, user_get_repositories, user_get_setting, |
26 | user_get_value, user_get_value_bio, user_get_value_display_name, |
27 | ; |
28 | use |
29 | repository_set_setting, repository_set_value, user_set_setting, user_set_value, |
30 | ; |
31 | |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | async |
38 | &self, |
39 | _object: O, |
40 | _operation: &str, |
41 | _payload: D, |
42 | _operation_state: &StackOperationState, |
43 | |
44 | // We don't handle operations with this backend |
45 | Err |
46 | |
47 | |
48 | async |
49 | &self, |
50 | _object_str: &str, |
51 | _operation_state: &StackOperationState, |
52 | |
53 | Err |
54 | |
55 | |
56 | |
57 | /// A backend implementation which attempts to resolve data from the instance's database. |
58 | |
59 | |
60 | pub(self) our_instance: Instance, |
61 | pub(self) user_backend: , |
62 | pub(self) repository_backend: , |
63 | |
64 | |
65 | |
66 | |
67 | instance: Instance, |
68 | user_backend: , |
69 | repository_backend: , |
70 | |
71 | Self |
72 | our_instance: instance, |
73 | user_backend, |
74 | repository_backend, |
75 | |
76 | |
77 | |
78 | |
79 | let mut handlers = default; |
80 | |
81 | handlers |
82 | .insert |
83 | .insert |
84 | .insert |
85 | .insert |
86 | .insert |
87 | .insert |
88 | .insert |
89 | .insert |
90 | .insert |
91 | .insert |
92 | .setting_getter |
93 | .setting_getter |
94 | .value_getter |
95 | .value_getter |
96 | .value_getter |
97 | .value_getter |
98 | . |
99 | . |
100 | . |
101 | . |
102 | . |
103 | . |
104 | . |
105 | .; |
106 | |
107 | new |
108 | |
109 | |
110 | |
111 | |
112 | |
113 | f.debug_struct .finish |
114 | |
115 | |
116 | |
117 | // TODO: These should be on the stack |
118 | // These tests verify that the essential handling of the database backend is |
119 | // functional and correct. |
120 | |
121 | |
122 | use ; |
123 | |
124 | use Error; |
125 | |
126 | use UserAuthenticationToken; |
127 | |
128 | use |
129 | AuthenticationTokenRequest, Instance, RegisterAccountRequest, RepositoryCreateRequest, |
130 | ; |
131 | |
132 | use ObjectBackend; |
133 | |
134 | use |
135 | Commit, Description, Repository, RepositoryCommitBeforeRequest, RepositoryDiff, |
136 | RepositoryDiffPatchRequest, RepositoryDiffRequest, RepositoryFile, |
137 | RepositoryFileFromIdRequest, RepositoryFileFromPathRequest, RepositoryFileInspectRequest, |
138 | RepositorySummary, RepositoryTreeEntry, |
139 | ; |
140 | use AnySetting; |
141 | use ; |
142 | use ; |
143 | use GiteratedBackend; |
144 | use ; |
145 | use Value; |
146 | use Mutex; |
147 | |
148 | use crate; |
149 | |
150 | use DatabaseBackend; |
151 | ; |
152 | |
153 | |
154 | |
155 | async |
156 | assert_eq!; |
157 | |
158 | Ok |
159 | & to_vec .unwrap, |
160 | |
161 | .unwrap |
162 | |
163 | async |
164 | Ok |
165 | & to_vec .unwrap, |
166 | |
167 | .unwrap |
168 | |
169 | async |
170 | &mut self, |
171 | _user: &User, |
172 | _name: &str, |
173 | _setting: &Value, |
174 | |
175 | Ok |
176 | |
177 | async |
178 | Ok |
179 | |
180 | async |
181 | &mut self, |
182 | _requester: & , |
183 | _user: &User, |
184 | |
185 | todo! |
186 | |
187 | |
188 | |
189 | |
190 | |
191 | async |
192 | &mut self, |
193 | _request: RegisterAccountRequest, |
194 | |
195 | todo! |
196 | |
197 | |
198 | async |
199 | &mut self, |
200 | _source: &Instance, |
201 | _request: AuthenticationTokenRequest, |
202 | |
203 | todo! |
204 | |
205 | |
206 | |
207 | ; |
208 | |
209 | |
210 | |
211 | async |
212 | &mut self, |
213 | _user: &AuthenticatedUser, |
214 | _request: &RepositoryCreateRequest, |
215 | |
216 | todo! |
217 | |
218 | async |
219 | &mut self, |
220 | _requester: & , |
221 | _repository: &Repository, |
222 | _request: &RepositoryFileInspectRequest, |
223 | |
224 | todo! |
225 | |
226 | async |
227 | &mut self, |
228 | _requester: & , |
229 | _repository: &Repository, |
230 | _request: &RepositoryFileFromIdRequest, |
231 | |
232 | todo! |
233 | |
234 | async |
235 | &mut self, |
236 | _requester: & , |
237 | _repository: &Repository, |
238 | _request: &RepositoryFileFromPathRequest, |
239 | |
240 | todo! |
241 | |
242 | async |
243 | &mut self, |
244 | _requester: & , |
245 | _repository: &Repository, |
246 | _request: &RepositoryDiffRequest, |
247 | |
248 | todo! |
249 | |
250 | async |
251 | &mut self, |
252 | _requester: & , |
253 | _repository: &Repository, |
254 | _request: &RepositoryDiffPatchRequest, |
255 | |
256 | todo! |
257 | |
258 | async |
259 | &mut self, |
260 | _requester: & , |
261 | _repository: &Repository, |
262 | _request: &RepositoryCommitBeforeRequest, |
263 | |
264 | todo! |
265 | |
266 | async |
267 | &mut self, |
268 | _repository: &Repository, |
269 | _name: &str, |
270 | |
271 | Ok |
272 | & to_vec .unwrap, |
273 | |
274 | .unwrap |
275 | |
276 | async |
277 | &mut self, |
278 | _repository: &Repository, |
279 | _name: &str, |
280 | |
281 | Ok |
282 | & to_vec .unwrap, |
283 | |
284 | .unwrap |
285 | |
286 | async |
287 | &mut self, |
288 | _repository: &Repository, |
289 | _name: &str, |
290 | _setting: &Value, |
291 | |
292 | Ok |
293 | |
294 | |
295 | async |
296 | &mut self, |
297 | _requester: & , |
298 | repository: &Repository, |
299 | |
300 | // Ok(true) |
301 | Ok |
302 | == & from_str |
303 | "test_user:test.giterated.dev/[email protected]", |
304 | |
305 | .unwrap |
306 | |
307 | |
308 | |
309 | |
310 | DatabaseBackend |
311 | our_instance: from_str .unwrap, |
312 | user_backend: new as _, |
313 | repository_backend: new as _, |
314 | |
315 | .into_backend |
316 | |
317 | |
318 | |
319 | todo! |
320 | |
321 | |
322 | |
323 | async |
324 | let backend = test_backend; |
325 | let operation_state = operation_state; |
326 | |
327 | let mut user = backend |
328 | . |
329 | .await |
330 | .expect; |
331 | |
332 | user. |
333 | .await |
334 | .expect; |
335 | |
336 | |
337 | |
338 | async |
339 | let backend = test_backend; |
340 | let operation_state = operation_state; |
341 | |
342 | let mut user = backend |
343 | . |
344 | .await |
345 | .expect; |
346 | |
347 | user. |
348 | .await |
349 | .expect; |
350 | |
351 | |
352 | |
353 | async |
354 | let backend = test_backend; |
355 | let operation_state = operation_state; |
356 | |
357 | let mut user = backend |
358 | . |
359 | .await |
360 | .expect; |
361 | |
362 | user. |
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 | |
387 | async |
388 | let backend = test_backend; |
389 | let operation_state = operation_state; |
390 | |
391 | let mut repository = backend |
392 | . |
393 | "test_user:test.giterated.dev/[email protected]", |
394 | &operation_state, |
395 | |
396 | .await |
397 | .expect; |
398 | |
399 | repository |
400 | . |
401 | .await |
402 | .expect; |
403 | |
404 | |
405 | |
406 | async |
407 | let backend = test_backend; |
408 | let operation_state = operation_state; |
409 | |
410 | let mut repository = backend |
411 | . |
412 | "test_user:test.giterated.dev/[email protected]", |
413 | &operation_state, |
414 | |
415 | .await |
416 | .expect; |
417 | |
418 | repository |
419 | . |
420 | .await |
421 | .expect; |
422 | |
423 | |
424 |