Giterated Stack `ObjectValue` and `Setting` refactor.
This refactor adds value and setting update events, as well as value getters. Additionally, the stack is now the owner of the ability to write settings into storage. This is accomplished with the `MetadataProvider` trait. This sets up the ground work for push federation, cache, and basically everything else. commit 7befc583cb3e0c6719506c550ed66ac76293413c Author: Amber <[email protected]> Date: Fri Sep 29 15:46:48 2023 -0500 Finish value and settings refactor in the stack. commit 3ac09994a0caafd1a0b95d9a781c7f202f20e75b Author: Amber <[email protected]> Date: Fri Sep 29 09:46:32 2023 -0500 Add set_setting handling back in commit 84fd31e3eae85d98fa68a28b333dbb32cde3bdb8 Author: Amber <[email protected]> Date: Wed Sep 27 06:36:31 2023 -0500 Remove some allocations from meta types commit 16c310ce3680c4a14ed35083b6a230aaecd43152 Author: Amber <[email protected]> Date: Wed Sep 27 05:35:03 2023 -0500 Add cargo metadata commit eb2520a20001bac7b21c6c3d34f62db32f0ada80 Author: Amber <[email protected]> Date: Wed Sep 27 05:26:27 2023 -0500 Refactor setting and value management to use the unified stack. Allows for tight management, inspection, and eventing of setting and value management. commit 901fe103da0fce4b40f33b0a8b64404049ae03cf Author: Amber <[email protected]> Date: Wed Sep 27 02:38:33 2023 -0500 Set up ground work for value / settings refactor
parent: tbd commit: c377e4d
1 | |
2 | |
3 | |
4 | pub use ; |
5 | pub use *; |
6 | use ; |
7 | |
8 | |
9 | |
10 | use ; |
11 | |
12 | use Debug; |
13 | use FutureExt; |
14 | use |
15 | , |
16 | |
17 | AuthenticationTokenRequest, Instance, RegisterAccountRequest, RepositoryCreateRequest, |
18 | , |
19 | , | GiteratedObject
20 | , | ObjectBackend
21 | , | GiteratedOperation
22 | , |
23 | , |
24 | , | User
25 | , |
26 | ; |
27 | |
28 | |
29 | |
30 | pub object_name: String, |
31 | pub operation_name: String, |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | Self |
38 | object_name: object_name .to_string, |
39 | operation_name: operation_name .to_string, |
40 | |
41 | |
42 | |
43 | |
44 | |
45 | |
46 | pub object_kind: String, |
47 | pub value_kind: String, |
48 | |
49 | |
50 | |
51 | |
52 | Self |
53 | object_kind: object_name .to_string, |
54 | value_kind: value_name .to_string, |
55 | |
56 | |
57 | |
58 | |
59 | |
60 | |
61 | pub object_kind: String, |
62 | pub setting_name: String, |
63 | |
64 | |
65 | |
66 | |
67 | Self |
68 | object_kind: object_name .to_string, |
69 | setting_name: name .to_string, |
70 | |
71 | |
72 | |
73 | |
74 | |
75 | |
76 | L, |
77 | O: GiteratedObject, |
78 | D: GiteratedOperation<O>, |
79 | S: Send + Sync + Clone, |
80 | > |
81 | |
82 | ; |
83 | ; |
84 | |
85 | async |
86 | &self, |
87 | object: &O, |
88 | operation: D, |
89 | state: S, |
90 | operation_state: &StackOperationState, |
91 | ; |
92 | |
93 | |
94 | |
95 | |
96 | |
97 | F: FnMut( |
98 | &O, |
99 | D, |
100 | S, |
101 | ) |
102 | -> |
103 | + Send |
104 | + Sync |
105 | + Clone, |
106 | O: GiteratedObject + Send + Sync, |
107 | D: + 'static, |
108 | : Send, | Failure
109 | S: Send + Sync + Clone + 'static, |
110 | |
111 | |
112 | operation_name |
113 | |
114 | |
115 | |
116 | object_name |
117 | |
118 | |
119 | async |
120 | &self, |
121 | object: &O, |
122 | operation: D, |
123 | state: S, |
124 | _operation_state: &StackOperationState, |
125 | |
126 | self.clone .await |
127 | |
128 | |
129 | |
130 | |
131 | |
132 | |
133 | F: FnMut( |
134 | &O, |
135 | D, |
136 | S, |
137 | O1, |
138 | ) |
139 | -> |
140 | + Send |
141 | + Sync |
142 | + Clone, |
143 | O: GiteratedObject + Send + Sync, |
144 | D: + 'static + Send + Sync, |
145 | : Send, | Failure
146 | S: Send + Sync + Clone + 'static, |
147 | O1: , |
148 | : , |
149 | |
150 | |
151 | operation_name |
152 | |
153 | |
154 | |
155 | object_name |
156 | |
157 | |
158 | async |
159 | &self, |
160 | object: &O, |
161 | operation: D, |
162 | state: S, |
163 | operation_state: &StackOperationState, |
164 | |
165 | let o1 = O1 from_state |
166 | .await |
167 | .as_internal_error?; |
168 | self.clone .await |
169 | |
170 | |
171 | |
172 | |
173 | |
174 | |
175 | F: FnMut( |
176 | &O, |
177 | D, |
178 | S, |
179 | O1, |
180 | O2, |
181 | ) |
182 | -> |
183 | + Send |
184 | + Sync |
185 | + Clone, |
186 | O: GiteratedObject + Send + Sync, |
187 | D: + 'static + Send + Sync, |
188 | : Send, | Failure
189 | S: Send + Sync + Clone + 'static, |
190 | O1: , |
191 | : , |
192 | O2: , |
193 | : , |
194 | |
195 | |
196 | operation_name |
197 | |
198 | |
199 | |
200 | object_name |
201 | |
202 | |
203 | async |
204 | &self, |
205 | object: &O, |
206 | operation: D, |
207 | state: S, |
208 | operation_state: &StackOperationState, |
209 | |
210 | let o1 = O1 from_state |
211 | .await |
212 | .as_internal_error?; |
213 | let o2 = O2 from_state |
214 | .await |
215 | .as_internal_error?; |
216 | self.clone .await |
217 | |
218 | |
219 | |
220 | |
221 | |
222 | |
223 | F: FnMut( |
224 | &O, |
225 | D, |
226 | S, |
227 | O1, |
228 | O2, |
229 | O3, |
230 | ) |
231 | -> |
232 | + Send |
233 | + Sync |
234 | + Clone, |
235 | O: GiteratedObject + Send + Sync, |
236 | D: + 'static + Send + Sync, |
237 | : Send, | Failure
238 | S: Send + Sync + Clone + 'static, |
239 | O1: , |
240 | : , |
241 | O2: , |
242 | : , |
243 | O3: , |
244 | : , |
245 | |
246 | |
247 | operation_name |
248 | |
249 | |
250 | |
251 | object_name |
252 | |
253 | |
254 | async |
255 | &self, |
256 | object: &O, |
257 | operation: D, |
258 | state: S, |
259 | operation_state: &StackOperationState, |
260 | |
261 | let o1 = O1 from_state |
262 | .await |
263 | .as_internal_error?; |
264 | let o2 = O2 from_state |
265 | .await |
266 | .as_internal_error?; |
267 | let o3 = O3 from_state |
268 | .await |
269 | .as_internal_error?; |
270 | self.clone .await |
271 | |
272 | |
273 | |
274 | |
275 | func: |
276 | dyn Fn( |
277 | &(dyn Any + Send + Sync), |
278 | &(dyn Any + Send + Sync), |
279 | &(dyn Any + Send + Sync), |
280 | StackOperationState, |
281 | ) -> |
282 | |
283 | dyn |
284 | Output = |
285 | , |
286 | , |
287 | >, |
288 | >, |
289 | >, |
290 | > + Send |
291 | + Sync, |
292 | >, |
293 | state: , |
294 | |
295 | |
296 | |
297 | |
298 | A, |
299 | O: GiteratedObject + Send + Sync + 'static, |
300 | D: + 'static + Clone, |
301 | F: + 'static + Send + Sync + Clone, |
302 | S: GiteratedStackState + 'static, |
303 | > |
304 | handler: F, |
305 | state: S, |
306 | |
307 | |
308 | : Send + Sync, | Failure
309 | : Send + Sync, | Success
310 | |
311 | Self |
312 | func: Box new |
313 | let handler = handler.clone; |
314 | let state = state. .unwrap .clone; |
315 | let object: &O = object.downcast_ref .unwrap; |
316 | let operation: &D = operation.downcast_ref .unwrap; |
317 | let object = object.clone; |
318 | let operation = operation.clone; |
319 | async move |
320 | let result = handler |
321 | .handle |
322 | .await; |
323 | result |
324 | .map |
325 | .map_err |
326 | => | Operation
327 | Operation |
328 | |
329 | => | Internal
330 | Internal |
331 | |
332 | => Unhandled, | Unhandled
333 | |
334 | |
335 | .boxed_local |
336 | , |
337 | state: Box new, |
338 | |
339 | |
340 | |
341 | async |
342 | &self, |
343 | object: & , |
344 | operation: & , |
345 | operation_state: &StackOperationState, |
346 | |
347 | |
348 | as_ref, | .
349 | as_ref, | .
350 | self.state.as_ref, |
351 | operation_state.clone, |
352 | |
353 | .await |
354 | |
355 | |
356 | |
357 | |
358 | |
359 | type Error: ; |
360 | |
361 | async |
362 | object: &O, |
363 | operation: &D, |
364 | state: &StackOperationState, |
365 | ; |
366 | |
367 | |
368 | |
369 | |
370 | for Arc |
371 | |
372 | type Error = Infallible; |
373 | |
374 | async |
375 | _object: &O, |
376 | _operation: &D, |
377 | state: &StackOperationState, |
378 | |
379 | Ok |
380 | |
381 | |
382 | |
383 | |
384 | |
385 | for StackOperationState |
386 | |
387 | type Error = Infallible; |
388 | |
389 | async |
390 | _object: &O, |
391 | _operation: &D, |
392 | state: &StackOperationState, |
393 | |
394 | Ok |
395 | |
396 | |
397 | |
398 | |
399 | |
400 | ; |
401 | |
402 | |
403 | |
404 | for AuthenticatedUser |
405 | |
406 | type Error = MissingValue; |
407 | |
408 | async |
409 | _object: &O, |
410 | _operation: &D, |
411 | state: &StackOperationState, |
412 | |
413 | state.user.clone .ok_or |
414 | |
415 | |
416 | |
417 | |
418 | |
419 | for AuthenticatedInstance |
420 | |
421 | type Error = MissingValue; |
422 | |
423 | async |
424 | _object: &O, |
425 | _operation: &D, |
426 | state: &StackOperationState, |
427 | |
428 | state.instance.clone .ok_or |
429 | |
430 | |
431 | |
432 | |
433 | |
434 | T: + Send + Sync, |
435 | O: GiteratedObject + Sync, |
436 | D: + Send + Sync, |
437 | > |
438 | |
439 | type Error = Infallible; |
440 | |
441 | async |
442 | object: &O, |
443 | operation: &D, |
444 | state: &StackOperationState, |
445 | |
446 | Ok |
447 | |
448 | |
449 | |
450 | |
451 | ; |
452 | |
453 | |
454 | ; |
455 | |
456 | |
457 | |
458 | type Error: ; |
459 | |
460 | async |
461 | &self, |
462 | authorize_for: &O, |
463 | state: &StackOperationState, |
464 | ; |
465 | |
466 | |
467 | |
468 | |
469 | type Error = Error; |
470 | |
471 | async |
472 | &self, |
473 | authorize_for: &O, |
474 | operation_state: &StackOperationState, |
475 | |
476 | Ok |
477 | .runtime |
478 | . |
479 | .await |
480 | .is_ok |
481 | |
482 | |
483 | |
484 | |
485 | |
486 | type Error = MissingValue; |
487 | |
488 | async |
489 | &self, |
490 | authorize_for: &User, |
491 | operation_state: &StackOperationState, |
492 | |
493 | let authenticated_user = operation_state.user.as_ref .ok_or?; |
494 | |
495 | Ok |
496 | |
497 | |
498 | |
499 | |
500 | |
501 | type Error = MissingValue; |
502 | |
503 | async |
504 | &self, |
505 | authorize_for: &User, |
506 | operation_state: &StackOperationState, |
507 | |
508 | let authenticated_user = operation_state.user.as_ref .ok_or?; |
509 | |
510 | Ok |
511 | |
512 | |
513 | |
514 | |
515 | |
516 | type Error = Error; |
517 | |
518 | async |
519 | &self, |
520 | authorize_for: &Repository, |
521 | operation_state: &StackOperationState, |
522 | |
523 | let authenticated_user = operation_state |
524 | .user |
525 | .as_ref |
526 | .ok_or_else?; |
527 | |
528 | let mut object = operation_state |
529 | .runtime |
530 | . |
531 | .await |
532 | .map_err?; |
533 | |
534 | let access_list = object |
535 | . |
536 | .await |
537 | .map_err?; |
538 | |
539 | if access_list |
540 | .0 |
541 | .iter |
542 | .any |
543 | |
544 | Ok |
545 | else |
546 | Ok |
547 | |
548 | |
549 | |
550 | |
551 | |
552 | |
553 | type Error = Error; |
554 | |
555 | async |
556 | &self, |
557 | authorize_for: &Repository, |
558 | operation_state: &StackOperationState, |
559 | |
560 | let authenticated_user = operation_state |
561 | .user |
562 | .as_ref |
563 | .ok_or_else?; |
564 | |
565 | let mut object = operation_state |
566 | .runtime |
567 | . |
568 | .await |
569 | .map_err?; |
570 | |
571 | let access_list = object |
572 | . |
573 | .await |
574 | .map_err?; |
575 | |
576 | if access_list |
577 | .0 |
578 | .iter |
579 | .any |
580 | |
581 | Ok |
582 | else |
583 | Ok |
584 | |
585 | |
586 | |
587 | |
588 | |
589 | |
590 | type Error = Infallible; |
591 | |
592 | async |
593 | &self, |
594 | authorize_for: &Instance, |
595 | state: &StackOperationState, |
596 | |
597 | if state.our_instance == *authorize_for |
598 | Ok |
599 | else |
600 | Ok |
601 | |
602 | |
603 | |
604 | |
605 | |
606 | |
607 | type Error = Infallible; |
608 | |
609 | async |
610 | &self, |
611 | authorize_for: &Instance, |
612 | state: &StackOperationState, |
613 | |
614 | if state.our_instance == *authorize_for |
615 | Ok |
616 | else |
617 | Ok |
618 | |
619 | |
620 | |
621 | |
622 | |
623 | |
624 | type Error = Infallible; |
625 | |
626 | async |
627 | &self, |
628 | authorize_for: &Instance, |
629 | state: &StackOperationState, |
630 | |
631 | if state.our_instance == *authorize_for |
632 | Ok |
633 | else |
634 | Ok |
635 | |
636 | |
637 | |
638 | |
639 | |
640 | |
641 | type Error = UnauthorizedError; |
642 | |
643 | async |
644 | object: &User, |
645 | operation: &A, |
646 | state: &StackOperationState, |
647 | |
648 | // TODO |
649 | let authenticated = from_state |
650 | .await |
651 | .map_err?; |
652 | |
653 | match operation.authorize .await |
654 | Ok => |
655 | assert!; |
656 | |
657 | Err => return Err, |
658 | ; |
659 | |
660 | Ok |
661 | |
662 | |
663 | |
664 | |
665 | |
666 | for AuthorizedInstance |
667 | |
668 | type Error = UnauthorizedError; |
669 | |
670 | async |
671 | object: &Instance, |
672 | operation: &A, |
673 | state: &StackOperationState, |
674 | |
675 | //TODO |
676 | let authenticated = from_state |
677 | .await |
678 | .map_err?; |
679 | |
680 | match operation.authorize .await |
681 | Ok => |
682 | assert!; |
683 | |
684 | Err => return Err, |
685 | ; |
686 | |
687 | Ok |
688 | |
689 | |
690 | |
691 | // #[async_trait::async_trait> FromOperationState for Option<T> { |
692 | // type Error = (); |
693 | |
694 | // async fn from_state(state: &StackOperationState) -> Result<Option<T>, OperationError<()>> { |
695 | // Ok(T::from_state(] |
696 | // impl<T: FromOperationStatestate).await.ok()) |
697 | // } |
698 | // } |
699 | |
700 | |
701 | |
702 | pub our_instance: Instance, |
703 | pub runtime: , |
704 | pub instance: , |
705 | pub user: , |
706 | |
707 | |
708 | |
709 | ; |
710 | |
711 | |
712 | |
713 | AuthenticatedInstance |
714 | |
715 | |
716 | |
717 | |
718 | type Target = Instance; |
719 | |
720 | |
721 | &self.0 |
722 | |
723 | |
724 | |
725 | |
726 | ; |
727 | |
728 | |
729 | |
730 | AuthenticatedUser |
731 | |
732 | |
733 | |
734 | |
735 | type Target = User; |
736 | |
737 | |
738 | &self.0 |
739 | |
740 | |
741 | |
742 | |
743 | |
744 | |
745 | ; |
746 | |
747 | |
748 | |
749 | O: GiteratedObject, |
750 | S: Setting + Serialize + DeserializeOwned, |
751 | |
752 | type Success = ; |
753 | |
754 | type Failure = ; |
755 | |
756 |