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 | use Error; |
2 | |
3 | use ; |
4 | use |
5 | , |
6 | , | ObjectBackend
7 | |
8 | Commit, DefaultBranch, Description, LatestCommit, Repository, |
9 | RepositoryCommitBeforeRequest, RepositoryDiff, RepositoryDiffRequest, RepositoryFile, |
10 | RepositoryFileFromIdRequest, RepositoryFileInspectRequest, RepositoryInfoRequest, |
11 | RepositorySummary, RepositoryView, Visibility, |
12 | , |
13 | , |
14 | , |
15 | , |
16 | ; |
17 | use ; |
18 | |
19 | use DatabaseBackend; |
20 | |
21 | |
22 | object: &User, |
23 | _operation: UserRepositoriesRequest, |
24 | state: DatabaseBackend, |
25 | |
26 | let object = object.clone; |
27 | |
28 | async move |
29 | let mut user_backend = state.user_backend.lock .await; |
30 | let repositories = user_backend |
31 | .repositories_for_user |
32 | .await |
33 | .map_err?; |
34 | |
35 | Ok |
36 | |
37 | .boxed |
38 | |
39 | |
40 | |
41 | object: &User, |
42 | operation: , |
43 | state: DatabaseBackend, |
44 | |
45 | let object = object.clone; |
46 | |
47 | async move |
48 | let mut user_backend = state.user_backend.lock .await; |
49 | let value = user_backend |
50 | .get_value |
51 | .await |
52 | .map_err?; |
53 | |
54 | Ok |
55 | |
56 | .boxed |
57 | |
58 | |
59 | |
60 | object: &User, |
61 | operation: , |
62 | state: DatabaseBackend, |
63 | |
64 | let object = object.clone; |
65 | |
66 | async move |
67 | let mut user_backend = state.user_backend.lock .await; |
68 | let value = user_backend |
69 | .get_setting |
70 | .await |
71 | .map_err?; |
72 | |
73 | Ok |
74 | |
75 | .boxed |
76 | |
77 | |
78 | |
79 | object: &User, |
80 | operation: , |
81 | state: DatabaseBackend, |
82 | |
83 | let object = object.clone; |
84 | |
85 | async move |
86 | let mut user_backend = state.user_backend.lock .await; |
87 | let value = user_backend |
88 | .write_setting |
89 | .await |
90 | .map_err?; |
91 | |
92 | Ok |
93 | |
94 | .boxed |
95 | |
96 | |
97 | |
98 | object: &Repository, |
99 | operation: RepositoryInfoRequest, |
100 | state: DatabaseBackend, |
101 | operation_state: StackOperationState, |
102 | backend: BackendWrapper, |
103 | |
104 | let object = object.clone; |
105 | |
106 | async move |
107 | let mut object = backend |
108 | . |
109 | .await |
110 | .unwrap; |
111 | |
112 | let mut repository_backend = state.repository_backend.lock .await; |
113 | let tree = repository_backend |
114 | .repository_file_inspect |
115 | None, |
116 | object.object, |
117 | &RepositoryFileInspectRequest |
118 | extra_metadata: operation.extra_metadata, |
119 | path: operation.path, |
120 | rev: operation.rev.clone, |
121 | , |
122 | |
123 | .await |
124 | .map_err?; |
125 | drop; |
126 | |
127 | let info = RepositoryView |
128 | name: object.object .name.clone, |
129 | owner: object.object .owner.clone, |
130 | description: object. .await.ok, |
131 | visibility: object |
132 | . |
133 | .await |
134 | .map_err?, |
135 | default_branch: object |
136 | . |
137 | .await |
138 | .map_err?, |
139 | // TODO: Can't be a simple get function, this needs to be returned alongside the tree as this differs depending on the rev and path. |
140 | latest_commit: object. .await.ok, |
141 | tree_rev: operation.rev, |
142 | tree, |
143 | ; |
144 | |
145 | Ok |
146 | |
147 | .boxed |
148 | |
149 | |
150 | |
151 | object: &Repository, |
152 | operation: RepositoryFileFromIdRequest, |
153 | state: DatabaseBackend, |
154 | operation_state: StackOperationState, |
155 | backend: BackendWrapper, |
156 | |
157 | let object = object.clone; |
158 | |
159 | async move |
160 | let object = backend |
161 | . |
162 | .await |
163 | .unwrap; |
164 | |
165 | let mut repository_backend = state.repository_backend.lock .await; |
166 | let file = repository_backend |
167 | .repository_file_from_id |
168 | None, |
169 | object.object, |
170 | &RepositoryFileFromIdRequest, |
171 | |
172 | .await |
173 | .map_err?; |
174 | drop; |
175 | |
176 | Ok |
177 | |
178 | .boxed |
179 | |
180 | |
181 | |
182 | object: &Repository, |
183 | operation: RepositoryDiffRequest, |
184 | state: DatabaseBackend, |
185 | operation_state: StackOperationState, |
186 | backend: BackendWrapper, |
187 | |
188 | let object = object.clone; |
189 | |
190 | async move |
191 | let object = backend |
192 | . |
193 | .await |
194 | .unwrap; |
195 | |
196 | let mut repository_backend = state.repository_backend.lock .await; |
197 | let file = repository_backend |
198 | .repository_diff |
199 | .await |
200 | .map_err?; |
201 | drop; |
202 | |
203 | Ok |
204 | |
205 | .boxed |
206 | |
207 | |
208 | |
209 | object: &Repository, |
210 | operation: RepositoryCommitBeforeRequest, |
211 | state: DatabaseBackend, |
212 | operation_state: StackOperationState, |
213 | backend: BackendWrapper, |
214 | |
215 | let object = object.clone; |
216 | |
217 | async move |
218 | let object = backend |
219 | . |
220 | .await |
221 | .unwrap; |
222 | |
223 | let mut repository_backend = state.repository_backend.lock .await; |
224 | let file = repository_backend |
225 | .repository_commit_before |
226 | .await |
227 | .map_err?; |
228 | drop; |
229 | |
230 | Ok |
231 | |
232 | .boxed |
233 | |
234 | |
235 | |
236 | object: &Repository, |
237 | operation: , |
238 | state: DatabaseBackend, |
239 | |
240 | let object = object.clone; |
241 | |
242 | async move |
243 | let mut repository_backend = state.repository_backend.lock .await; |
244 | let value = repository_backend |
245 | .get_value |
246 | .await |
247 | .map_err |
248 | Internal |
249 | ?; |
250 | |
251 | Ok |
252 | |
253 | .boxed |
254 | |
255 | |
256 | |
257 | object: &Repository, |
258 | operation: , |
259 | state: DatabaseBackend, |
260 | |
261 | let object = object.clone; |
262 | |
263 | async move |
264 | let mut repository_backend = state.repository_backend.lock .await; |
265 | let value = repository_backend |
266 | .get_setting |
267 | .await |
268 | .map_err?; |
269 | |
270 | Ok |
271 | |
272 | .boxed |
273 | |
274 | |
275 | |
276 | object: &Repository, |
277 | operation: , |
278 | state: DatabaseBackend, |
279 | |
280 | let object = object.clone; |
281 | |
282 | async move |
283 | let mut repository_backend = state.repository_backend.lock .await; |
284 | let value = repository_backend |
285 | .write_setting |
286 | .await |
287 | .map_err?; |
288 | |
289 | Ok |
290 | |
291 | .boxed |
292 | |
293 |