JavaScript is disabled, refresh for a better experience. ambee/giterated

ambee/giterated

Git repository hosting, collaboration, and discovery for the Fediverse.

Unified stack refactor clean up

Clean up obsolete code and some warnings

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨356f714

Showing ⁨⁨15⁩ changed files⁩ with ⁨⁨56⁩ insertions⁩ and ⁨⁨1126⁩ deletions⁩

giterated-daemon/src/authorization.rs

View file
@@ -12,7 +12,7 @@ use giterated_models::user::User;
12 12
13 13 use giterated_models::{
14 14 object::ObjectRequest,
15 settings::{SetSetting, Setting},
15 settings::SetSetting,
16 16 value::{GetValue, GiteratedObjectValue},
17 17 };
18 18 #[async_trait::async_trait]

giterated-daemon/src/connection/wrapper.rs

View file
@@ -39,7 +39,6 @@ use toml::Table;
39 39 use crate::{
40 40 authentication::AuthenticationTokenGranter,
41 41 backend::{MetadataBackend, RepositoryBackend, UserBackend},
42 database_backend::DatabaseBackend,
43 42 federation::connections::InstanceConnections,
44 43 keys::PublicKeyCache,
45 44 };
@@ -206,112 +205,6 @@ pub async fn connection_wrapper(
206 205 }
207 206 }
208 207 }
209
210 // loop {
211 // let mut socket = connection_state.socket.lock().await;
212 // let message = socket.next().await;
213 // drop(socket);
214
215 // match message {
216 // Some(Ok(message)) => {
217 // let payload = match message {
218 // Message::Binary(payload) => payload,
219 // Message::Ping(_) => {
220 // let mut socket = connection_state.socket.lock().await;
221 // let _ = socket.send(Message::Pong(vec![])).await;
222 // drop(socket);
223 // continue;
224 // }
225 // Message::Close(_) => return,
226 // _ => continue,
227 // };
228
229 // let message = NetworkMessage(payload.clone());
230
231 // if !handshaked {
232 // if handshake_handle(&message, &connection_state).await.is_ok() {
233 // if connection_state.handshaked.load(Ordering::SeqCst) {
234 // handshaked = true;
235 // }
236 // }
237 // } else {
238 // let raw = serde_json::from_slice::<AuthenticatedPayload>(&payload).unwrap();
239
240 // if let Some(target_instance) = &raw.target_instance {
241 // if connection_state.instance != *target_instance {
242 // // Forward request
243 // info!("Forwarding message to {}", target_instance.url);
244 // let mut instance_connections = instance_connections.lock().await;
245 // let pool = instance_connections.get_or_open(&target_instance).unwrap();
246 // let pool_clone = pool.clone();
247 // drop(pool);
248
249 // let result = wrap_forwarded(&pool_clone, raw).await;
250
251 // let mut socket = connection_state.socket.lock().await;
252 // let _ = socket.send(result).await;
253
254 // continue;
255 // }
256 // }
257
258 // let message_type = &raw.message_type;
259
260 // match authentication_handle(message_type, &message, &connection_state).await {
261 // Err(e) => {
262 // let _ = connection_state
263 // .send_raw(ConnectionError(e.to_string()))
264 // .await;
265 // }
266 // Ok(true) => continue,
267 // Ok(false) => {}
268 // }
269
270 // match repository_handle(message_type, &message, &connection_state).await {
271 // Err(e) => {
272 // let _ = connection_state
273 // .send_raw(ConnectionError(e.to_string()))
274 // .await;
275 // }
276 // Ok(true) => continue,
277 // Ok(false) => {}
278 // }
279
280 // match user_handle(message_type, &message, &connection_state).await {
281 // Err(e) => {
282 // let _ = connection_state
283 // .send_raw(ConnectionError(e.to_string()))
284 // .await;
285 // }
286 // Ok(true) => continue,
287 // Ok(false) => {}
288 // }
289
290 // match authentication_handle(message_type, &message, &connection_state).await {
291 // Err(e) => {
292 // let _ = connection_state
293 // .send_raw(ConnectionError(e.to_string()))
294 // .await;
295 // }
296 // Ok(true) => continue,
297 // Ok(false) => {}
298 // }
299
300 // error!(
301 // "Message completely unhandled: {}",
302 // std::str::from_utf8(&payload).unwrap()
303 // );
304 // }
305 // }
306 // Some(Err(e)) => {
307 // error!("Closing connection for {:?} for {}", e, addr);
308 // return;
309 // }
310 // _ => {
311 // continue;
312 // }
313 // }
314 // }
315 208 }
316 209
317 210 #[derive(Clone)]

giterated-daemon/src/database_backend/handler.rs

View file
@@ -9,19 +9,19 @@ use giterated_models::{
9 9 },
10 10 object_backend::ObjectBackend,
11 11 repository::{
12 AccessList, Commit, DefaultBranch, Description, LatestCommit, Repository,
12 Commit, DefaultBranch, Description, LatestCommit, Repository,
13 13 RepositoryCommitBeforeRequest, RepositoryDiff, RepositoryDiffPatchRequest,
14 14 RepositoryDiffRequest, RepositoryFile, RepositoryFileFromIdRequest,
15 15 RepositoryFileFromPathRequest, RepositoryFileInspectRequest, RepositoryInfoRequest,
16 16 RepositorySummary, RepositoryView, Visibility,
17 17 },
18 settings::{AnySetting, GetSetting, GetSettingError, SetSetting, SetSettingError},
18 settings::{AnySetting, GetSetting, GetSettingError},
19 19 user::{Bio, DisplayName, User, UserRepositoriesRequest},
20 20 value::{AnyValue, GetValue},
21 21 };
22 22 use giterated_stack::{
23 23 runtime::GiteratedRuntime, AuthenticatedUser, AuthorizedInstance, AuthorizedUser,
24 BackendWrapper, StackOperationState,
24 StackOperationState,
25 25 };
26 26
27 27 use super::DatabaseBackend;
@@ -30,7 +30,7 @@ pub fn user_get_repositories(
30 30 object: &User,
31 31 _operation: UserRepositoriesRequest,
32 32 state: DatabaseBackend,
33 operation_state: StackOperationState,
33 _operation_state: StackOperationState,
34 34 requester: Option<AuthenticatedUser>,
35 35 ) -> BoxFuture<'static, Result<Vec<RepositorySummary>, OperationError<UserError>>> {
36 36 let object = object.clone();
@@ -99,25 +99,6 @@ pub fn user_get_setting(
99 99 .boxed()
100 100 }
101 101
102 // pub fn user_set_setting(
103 // object: &User,
104 // operation: SetSetting<AnySetting>,
105 // state: DatabaseBackend,
106 // ) -> BoxFuture<'static, Result<(), OperationError<SetSettingError>>> {
107 // let object = object.clone();
108
109 // async move {
110 // let mut user_backend = state.user_backend.lock().await;
111 // let value = user_backend
112 // .write_setting(&object, &operation.setting_name, &operation.value.0)
113 // .await
114 // .map_err(|e| OperationError::Internal(e.to_string()))?;
115
116 // Ok(value)
117 // }
118 // .boxed()
119 // }
120
121 102 pub fn repository_info(
122 103 object: &Repository,
123 104 operation: RepositoryInfoRequest,
@@ -364,25 +345,6 @@ pub fn repository_get_setting(
364 345 .boxed()
365 346 }
366 347
367 // pub fn repository_set_setting(
368 // object: &Repository,
369 // operation: SetSetting<AnySetting>,
370 // state: DatabaseBackend,
371 // ) -> BoxFuture<'static, Result<(), OperationError<SetSettingError>>> {
372 // let object = object.clone();
373
374 // async move {
375 // let mut repository_backend = state.repository_backend.lock().await;
376 // let value = repository_backend
377 // .write_setting(&object, &operation.setting_name, &operation.value.0)
378 // .await
379 // .map_err(|e| OperationError::Internal(e.to_string()))?;
380
381 // Ok(value)
382 // }
383 // .boxed()
384 // }
385
386 348 pub fn instance_authentication_request(
387 349 object: &Instance,
388 350 operation: AuthenticationTokenRequest,

giterated-daemon/src/database_backend/mod.rs

View file
@@ -21,12 +21,8 @@ use self::handler::{
21 21 instance_authentication_request, instance_create_repository_request,
22 22 instance_registration_request, repository_commit_before, repository_diff,
23 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 self::updates::{
29 repository_set_setting, repository_set_value, user_set_setting, user_set_value,
24 repository_get_value_description, repository_get_value_visibility, repository_info,
25 user_get_value_bio, user_get_value_display_name,
30 26 };
31 27
32 28 #[derive(Clone, Debug)]
@@ -56,6 +52,7 @@ impl ObjectBackend<StackOperationState> for Foobackend {
56 52
57 53 /// A backend implementation which attempts to resolve data from the instance's database.
58 54 #[derive(Clone)]
55 #[allow(unused)]
59 56 pub struct DatabaseBackend {
60 57 pub(self) our_instance: Instance,
61 58 pub(self) user_backend: Arc<Mutex<dyn UserBackend + Send>>,
@@ -116,310 +113,3 @@ impl Debug for DatabaseBackend {
116 113 f.debug_struct("DatabaseBackend").finish()
117 114 }
118 115 }
119
120 // TODO: These should be on the stack
121 // These tests verify that the essential handling of the database backend is
122 // functional and correct.
123 // #[cfg(test)]
124 // mod test {
125 // use std::{str::FromStr, sync::Arc};
126
127 // use anyhow::Error;
128
129 // use giterated_models::authenticated::UserAuthenticationToken;
130
131 // use giterated_models::instance::{
132 // AuthenticationTokenRequest, Instance, RegisterAccountRequest, RepositoryCreateRequest,
133 // };
134
135 // use giterated_models::object_backend::ObjectBackend;
136
137 // use giterated_models::repository::{
138 // Commit, Description, Repository, RepositoryCommitBeforeRequest, RepositoryDiff,
139 // RepositoryDiffPatchRequest, RepositoryDiffRequest, RepositoryFile,
140 // RepositoryFileFromIdRequest, RepositoryFileFromPathRequest, RepositoryFileInspectRequest,
141 // RepositorySummary, RepositoryTreeEntry,
142 // };
143 // use giterated_models::settings::AnySetting;
144 // use giterated_models::user::{DisplayName, User};
145 // use giterated_models::value::{AnyValue, GiteratedObjectValue};
146 // use giterated_stack::{AuthenticatedUser, StackOperationState};
147 // use serde_json::Value;
148 // use tokio::sync::Mutex;
149
150 // use crate::backend::{git::GitBackendError, AuthBackend, RepositoryBackend, UserBackend};
151
152 // use super::DatabaseBackend;
153 // pub struct TestUserDatabaseBackend;
154
155 // #[async_trait::async_trait]
156 // impl UserBackend for TestUserDatabaseBackend {
157 // async fn get_value(&mut self, _user: &User, name: &str) -> Result<AnyValue<User>, Error> {
158 // assert_eq!(name, DisplayName::value_name());
159
160 // Ok(serde_json::from_slice(
161 // &serde_json::to_vec(&DisplayName(String::from("test"))).unwrap(),
162 // )
163 // .unwrap())
164 // }
165 // async fn get_setting(&mut self, _user: &User, _name: &str) -> Result<AnySetting, Error> {
166 // Ok(serde_json::from_slice(
167 // &serde_json::to_vec(&DisplayName(String::from("test"))).unwrap(),
168 // )
169 // .unwrap())
170 // }
171 // async fn write_setting(
172 // &mut self,
173 // _user: &User,
174 // _name: &str,
175 // _setting: &Value,
176 // ) -> Result<(), Error> {
177 // Ok(())
178 // }
179 // async fn exists(&mut self, user: &User) -> Result<bool, Error> {
180 // Ok(user == &User::from_str("test_user:test.giterated.dev").unwrap())
181 // }
182 // async fn repositories_for_user(
183 // &mut self,
184 // _requester: &Option<AuthenticatedUser>,
185 // _user: &User,
186 // ) -> Result<Vec<RepositorySummary>, Error> {
187 // todo!()
188 // }
189 // }
190
191 // #[async_trait::async_trait]
192 // impl AuthBackend for TestUserDatabaseBackend {
193 // async fn register(
194 // &mut self,
195 // _request: RegisterAccountRequest,
196 // ) -> Result<UserAuthenticationToken, Error> {
197 // todo!()
198 // }
199
200 // async fn login(
201 // &mut self,
202 // _source: &Instance,
203 // _request: AuthenticationTokenRequest,
204 // ) -> Result<UserAuthenticationToken, Error> {
205 // todo!()
206 // }
207 // }
208
209 // pub struct TestUserRepositoryBackend;
210
211 // #[async_trait::async_trait]
212 // impl RepositoryBackend for TestUserRepositoryBackend {
213 // async fn create_repository(
214 // &mut self,
215 // _user: &AuthenticatedUser,
216 // _request: &RepositoryCreateRequest,
217 // ) -> Result<Repository, GitBackendError> {
218 // todo!()
219 // }
220 // async fn repository_file_inspect(
221 // &mut self,
222 // _requester: &Option<AuthenticatedUser>,
223 // _repository: &Repository,
224 // _request: &RepositoryFileInspectRequest,
225 // ) -> Result<Vec<RepositoryTreeEntry>, Error> {
226 // todo!()
227 // }
228 // async fn repository_file_from_id(
229 // &mut self,
230 // _requester: &Option<AuthenticatedUser>,
231 // _repository: &Repository,
232 // _request: &RepositoryFileFromIdRequest,
233 // ) -> Result<RepositoryFile, Error> {
234 // todo!()
235 // }
236 // async fn repository_file_from_path(
237 // &mut self,
238 // _requester: &Option<AuthenticatedUser>,
239 // _repository: &Repository,
240 // _request: &RepositoryFileFromPathRequest,
241 // ) -> Result<RepositoryFile, Error> {
242 // todo!()
243 // }
244 // async fn repository_diff(
245 // &mut self,
246 // _requester: &Option<AuthenticatedUser>,
247 // _repository: &Repository,
248 // _request: &RepositoryDiffRequest,
249 // ) -> Result<RepositoryDiff, Error> {
250 // todo!()
251 // }
252 // async fn repository_diff_patch(
253 // &mut self,
254 // _requester: &Option<AuthenticatedUser>,
255 // _repository: &Repository,
256 // _request: &RepositoryDiffPatchRequest,
257 // ) -> Result<String, Error> {
258 // todo!()
259 // }
260 // async fn repository_commit_before(
261 // &mut self,
262 // _requester: &Option<AuthenticatedUser>,
263 // _repository: &Repository,
264 // _request: &RepositoryCommitBeforeRequest,
265 // ) -> Result<Commit, Error> {
266 // todo!()
267 // }
268 // async fn get_value(
269 // &mut self,
270 // _repository: &Repository,
271 // _name: &str,
272 // ) -> Result<AnyValue<Repository>, Error> {
273 // Ok(serde_json::from_slice(
274 // &serde_json::to_vec(&Description(String::from("test"))).unwrap(),
275 // )
276 // .unwrap())
277 // }
278 // async fn get_setting(
279 // &mut self,
280 // _repository: &Repository,
281 // _name: &str,
282 // ) -> Result<AnySetting, Error> {
283 // Ok(serde_json::from_slice(
284 // &serde_json::to_vec(&Description(String::from("test"))).unwrap(),
285 // )
286 // .unwrap())
287 // }
288 // async fn write_setting(
289 // &mut self,
290 // _repository: &Repository,
291 // _name: &str,
292 // _setting: &Value,
293 // ) -> Result<(), Error> {
294 // Ok(())
295 // }
296
297 // async fn exists(
298 // &mut self,
299 // _requester: &Option<AuthenticatedUser>,
300 // repository: &Repository,
301 // ) -> Result<bool, Error> {
302 // // Ok(true)
303 // Ok(repository
304 // == &Repository::from_str(
305 // "test_user:test.giterated.dev/[email protected]",
306 // )
307 // .unwrap())
308 // }
309 // }
310
311 // fn test_backend() -> GiteratedBackend<DatabaseBackend> {
312 // DatabaseBackend {
313 // our_instance: Instance::from_str("testing.giterated.dev").unwrap(),
314 // user_backend: Arc::new(Mutex::new(TestUserDatabaseBackend)) as _,
315 // repository_backend: Arc::new(Mutex::new(TestUserRepositoryBackend)) as _,
316 // }
317 // .into_backend()
318 // }
319
320 // fn operation_state() -> StackOperationState {
321 // todo!()
322 // }
323
324 // #[tokio::test]
325 // async fn test_user_get() {
326 // let backend = test_backend();
327 // let operation_state = operation_state();
328
329 // let mut user = backend
330 // .get_object::<User>("test_user:test.giterated.dev", &operation_state)
331 // .await
332 // .expect("object should have been returned");
333
334 // user.get::<DisplayName>(&operation_state)
335 // .await
336 // .expect("object value should have been returned");
337 // }
338
339 // #[tokio::test]
340 // async fn test_user_get_setting() {
341 // let backend = test_backend();
342 // let operation_state = operation_state();
343
344 // let mut user = backend
345 // .get_object::<User>("test_user:test.giterated.dev", &operation_state)
346 // .await
347 // .expect("object should have been returned");
348
349 // user.get_setting::<DisplayName>(&operation_state)
350 // .await
351 // .expect("object value should have been returned");
352 // }
353
354 // #[tokio::test]
355 // async fn test_user_set_setting() {
356 // let backend = test_backend();
357 // let operation_state = operation_state();
358
359 // let mut user = backend
360 // .get_object::<User>("test_user:test.giterated.dev", &operation_state)
361 // .await
362 // .expect("object should have been returned");
363
364 // user.set_setting::<DisplayName>(DisplayName(String::from("test")), &operation_state)
365 // .await
366 // .expect("object value should have been returned");
367 // }
368
369 // #[tokio::test]
370 // async fn test_respository_get() {
371 // let backend = test_backend();
372 // let operation_state = operation_state();
373
374 // let mut repository = backend
375 // .get_object::<Repository>(
376 // "test_user:test.giterated.dev/[email protected]",
377 // &operation_state,
378 // )
379 // .await
380 // .expect("object should have been returned");
381
382 // repository
383 // .get::<Description>(&operation_state)
384 // .await
385 // .expect("object value should have been returned");
386 // }
387
388 // #[tokio::test]
389 // async fn test_repository_get_setting() {
390 // let backend = test_backend();
391 // let operation_state = operation_state();
392
393 // let mut repository = backend
394 // .get_object::<Repository>(
395 // "test_user:test.giterated.dev/[email protected]",
396 // &operation_state,
397 // )
398 // .await
399 // .expect("object should have been returned");
400
401 // repository
402 // .get_setting::<Description>(&operation_state)
403 // .await
404 // .expect("object value should have been returned");
405 // }
406
407 // #[tokio::test]
408 // async fn test_repository_set_setting() {
409 // let backend = test_backend();
410 // let operation_state = operation_state();
411
412 // let mut repository = backend
413 // .get_object::<Repository>(
414 // "test_user:test.giterated.dev/[email protected]",
415 // &operation_state,
416 // )
417 // .await
418 // .expect("object should have been returned");
419
420 // repository
421 // .set_setting::<Description>(Description(String::from("test")), &operation_state)
422 // .await
423 // .expect("object value should have been returned");
424 // }
425 // }

giterated-daemon/src/database_backend/updates.rs

View file
@@ -11,45 +11,45 @@ use giterated_stack::{AuthorizedUser, StackOperationState};
11 11 use super::DatabaseBackend;
12 12
13 13 pub fn user_set_value(
14 object: User,
15 value_name: String,
16 value: AnyValue<User>,
17 operation_state: &StackOperationState,
14 _object: User,
15 _value_name: String,
16 _value: AnyValue<User>,
17 _operation_state: &StackOperationState,
18 18 ) -> BoxFuture<'static, Result<(), ()>> {
19 19 todo!()
20 20 }
21 21
22 22 pub fn user_set_setting(
23 object: User,
24 value_name: String,
25 value: AnySetting,
26 operation_state: &StackOperationState,
23 _object: User,
24 _value_name: String,
25 _value: AnySetting,
26 _operation_state: &StackOperationState,
27 27 ) -> BoxFuture<'static, Result<(), ()>> {
28 28 todo!()
29 29 }
30 30
31 31 pub fn repository_set_value(
32 object: Repository,
33 value_name: String,
34 value: AnyValue<Repository>,
35 operation_state: &StackOperationState,
32 _object: Repository,
33 _value_name: String,
34 _value: AnyValue<Repository>,
35 _operation_state: &StackOperationState,
36 36 ) -> BoxFuture<'static, Result<(), ()>> {
37 37 todo!()
38 38 }
39 39
40 40 pub fn repository_set_setting(
41 object: Repository,
42 value_name: String,
43 value: AnySetting,
44 operation_state: &StackOperationState,
41 _object: Repository,
42 _value_name: String,
43 _value: AnySetting,
44 _operation_state: &StackOperationState,
45 45 ) -> BoxFuture<'static, Result<(), ()>> {
46 46 todo!()
47 47 }
48 48
49 49 pub fn repository_set_description(
50 object: Repository,
51 description: Description,
52 user: AuthorizedUser,
50 _object: Repository,
51 _description: Description,
52 _user: AuthorizedUser,
53 53 ) -> BoxFuture<'static, Result<(), ()>> {
54 54 async { Ok(()) }.boxed()
55 55 }
@@ -73,7 +73,7 @@ pub fn repository_set_default_branch(
73 73 .await
74 74 .unwrap();
75 75
76 let set_value = ValueUpdate {
76 let _set_value = ValueUpdate {
77 77 object: object.to_string(),
78 78 value_name: DefaultBranch::value_name().to_owned(),
79 79 value: unsafe { AnyValue::from_raw(serde_json::to_value(default_branch).unwrap()) },

giterated-daemon/src/main.rs

View file
@@ -12,7 +12,7 @@ use giterated_daemon::{
12 12
13 13 use giterated_models::instance::Instance;
14 14
15 use giterated_stack::{runtime::GiteratedRuntime, BackendWrapper, StackOperationState};
15 use giterated_stack::{runtime::GiteratedRuntime, StackOperationState};
16 16 use sqlx::{postgres::PgConnectOptions, ConnectOptions, PgPool};
17 17 use std::{net::SocketAddr, str::FromStr, sync::Arc};
18 18 use tokio::{

giterated-models/src/authenticated.rs

View file
@@ -49,7 +49,7 @@ impl AuthenticatedPayload {
49 49 }
50 50 }
51 51 pub fn into_message_v2(self) -> GiteratedMessage<AnyObject, AnyOperationV2> {
52 let payload = serde_json::from_slice::<Value>(&self.payload).unwrap();
52 let _payload = serde_json::from_slice::<Value>(&self.payload).unwrap();
53 53 GiteratedMessage {
54 54 object: AnyObject(self.object),
55 55 operation: self.operation,

giterated-models/src/lib.rs

View file
@@ -1,7 +1,3 @@
1 use error::OperationError;
2 use object::GiteratedObject;
3 use operation::GiteratedOperation;
4
5 1 pub mod authenticated;
6 2 pub mod discovery;
7 3 pub mod error;

giterated-models/src/settings/operations.rs

View file
@@ -1,12 +1,12 @@
1 use std::{fmt::Debug, marker::PhantomData};
1 use std::fmt::Debug;
2 2
3 use serde::{de::DeserializeOwned, Deserialize, Serialize};
3 use serde::{Deserialize, Serialize};
4 4 use serde_json::Value;
5 5 use thiserror::Error;
6 6
7 7 use crate::{object::GiteratedObject, operation::GiteratedOperation};
8 8
9 use super::{AnySetting, Setting};
9 use super::AnySetting;
10 10
11 11 #[derive(Serialize, Deserialize, Debug, Clone)]
12 12 pub struct GetSetting {

giterated-models/src/update/instance.rs

View file
@@ -1 +1 @@
1 pub struct InstanceUpdate {}
1

giterated-models/src/update/mod.rs

View file
@@ -10,6 +10,7 @@ pub struct ValueUpdate {
10 10 pub value: AnyValue<()>,
11 11 }
12 12
13 #[allow(unused)]
13 14 pub struct SettingUpdate {
14 15 object: String,
15 16 value_name: String,

giterated-stack/src/handler.rs

View file
@@ -1,169 +1 @@
1 use giterated_models::{
2 error::OperationError,
3 instance::Instance,
4 object::{
5 AnyObject, GiteratedObject, Object, ObjectRequest, ObjectRequestError, ObjectResponse,
6 },
7 object_backend::ObjectBackend,
8 operation::{AnyOperation, GiteratedOperation},
9 };
10 use std::{any::Any, collections::HashMap, fmt::Debug, str::FromStr, sync::Arc};
11 use tokio::sync::Mutex;
12 use tracing::warn;
13 1
14 use crate::{
15 state::HandlerState,
16 update::{HandleSettingUpdatedFunction, HandleValueUpdatedFunction, ValueUpdateKind},
17 };
18
19 use crate::StackOperationState;
20
21 // #[derive(Clone)]
22 // pub struct GiteratedBackend<S: HandlerState> {
23 // state: S,
24 // handlers: Arc<OperationHandlers<S>>,
25 // }
26
27 // impl<S: HandlerState> GiteratedBackend<S> {
28 // pub fn new(state: S, handlers: OperationHandlers<S>) -> Self {
29 // Self {
30 // state,
31 // handlers: Arc::new(handlers),
32 // }
33 // }
34
35 // pub fn state(&self) -> &S {
36 // &self.state
37 // }
38 // }
39
40 // #[async_trait::async_trait]
41 // impl<S: HandlerState> ObjectBackend<StackOperationState> for GiteratedBackend<S> {
42 // async fn object_operation<O, D>(
43 // &self,
44 // object: O,
45 // operation: &str,
46 // payload: D,
47 // operation_state: &StackOperationState,
48 // ) -> Result<D::Success, OperationError<D::Failure>>
49 // where
50 // O: GiteratedObject + Debug + 'static,
51 // D: GiteratedOperation<O> + Debug,
52 // {
53 // let serialized =
54 // serde_json::to_value(payload).map_err(|e| OperationError::Internal(e.to_string()))?;
55 // let object = (Box::new(object) as Box<dyn Any + Send + Sync>)
56 // .downcast::<O>()
57 // .unwrap();
58
59 // if operation == ObjectRequest::operation_name() {
60 // // We're doing an object request
61 // let raw_result = self
62 // .handlers
63 // .resolve_object(
64 // *(Box::new(object) as Box<dyn Any + Send + Sync>)
65 // .downcast()
66 // .unwrap(),
67 // serde_json::from_value(serialized).unwrap(),
68 // self.state.clone(),
69 // &operation_state,
70 // )
71 // .await;
72
73 // return match raw_result {
74 // Ok(result) => Ok(serde_json::from_slice(&result)
75 // .map_err(|e| OperationError::Internal(e.to_string()))?),
76 // Err(err) => match err {
77 // OperationError::Internal(internal) => {
78 // warn!(
79 // "Internal Error: {:?}",
80 // OperationError::<()>::Internal(internal.clone())
81 // );
82
83 // Err(OperationError::Internal(internal))
84 // }
85 // OperationError::Unhandled => Err(OperationError::Unhandled),
86 // OperationError::Operation(err) => Err(OperationError::Operation(
87 // serde_json::from_slice(&err)
88 // .map_err(|e| OperationError::Internal(e.to_string()))?,
89 // )),
90 // },
91 // };
92 // }
93
94 // let raw_result = self
95 // .handlers
96 // .handle(
97 // &*object,
98 // operation,
99 // AnyOperation(serialized),
100 // self.state.clone(),
101 // &operation_state,
102 // )
103 // .await;
104
105 // match raw_result {
106 // Ok(result) => Ok(serde_json::from_slice(&result)
107 // .map_err(|e| OperationError::Internal(e.to_string()))?),
108 // Err(err) => match err {
109 // OperationError::Internal(internal) => {
110 // warn!(
111 // "Internal Error: {:?}",
112 // OperationError::<()>::Internal(internal.clone())
113 // );
114
115 // Err(OperationError::Internal(internal))
116 // }
117 // OperationError::Unhandled => Err(OperationError::Unhandled),
118 // OperationError::Operation(err) => Err(OperationError::Operation(
119 // serde_json::from_slice(&err)
120 // .map_err(|e| OperationError::Internal(e.to_string()))?,
121 // )),
122 // },
123 // }
124 // }
125
126 // async fn get_object<O: GiteratedObject + Debug>(
127 // &self,
128 // object_str: &str,
129 // operation_state: &StackOperationState,
130 // ) -> Result<Object<StackOperationState, O, Self>, OperationError<ObjectRequestError>> {
131 // let raw_result = self
132 // .handlers
133 // .resolve_object(
134 // Instance::from_str("giterated.dev").unwrap(),
135 // ObjectRequest(object_str.to_string()),
136 // self.state.clone(),
137 // operation_state,
138 // )
139 // .await;
140
141 // let object: ObjectResponse = match raw_result {
142 // Ok(result) => Ok(serde_json::from_slice(&result)
143 // .map_err(|e| OperationError::Internal(e.to_string()))?),
144 // Err(err) => match err {
145 // OperationError::Internal(internal) => {
146 // warn!(
147 // "Internal Error: {:?}",
148 // OperationError::<()>::Internal(internal.clone())
149 // );
150
151 // Err(OperationError::Internal(internal))
152 // }
153 // OperationError::Unhandled => Err(OperationError::Unhandled),
154 // OperationError::Operation(err) => Err(OperationError::Operation(
155 // serde_json::from_slice(&err)
156 // .map_err(|e| OperationError::Internal(e.to_string()))?,
157 // )),
158 // },
159 // }?;
160
161 // unsafe {
162 // Ok(Object::new_unchecked(
163 // O::from_str(&object.0)
164 // .map_err(|_| OperationError::Internal("deserialize failure".to_string()))?,
165 // self.clone(),
166 // ))
167 // }
168 // }
169 // }

giterated-stack/src/lib.rs

View file
@@ -3,39 +3,25 @@ pub mod runtime;
3 3 pub mod state;
4 4 pub mod update;
5 5
6 use std::{
7 any::Any, collections::HashMap, future::Future, ops::Deref, pin::Pin, str::FromStr, sync::Arc,
8 };
6 use std::{any::Any, future::Future, ops::Deref, pin::Pin, sync::Arc};
9 7
8 use core::fmt::Debug;
10 9 use futures_util::FutureExt;
11 10 use giterated_models::{
12 11 error::OperationError,
13 12 instance::{
14 13 AuthenticationTokenRequest, Instance, RegisterAccountRequest, RepositoryCreateRequest,
15 14 },
16 object::{
17 AnyObject, GiteratedObject, Object, ObjectRequest, ObjectRequestError, ObjectResponse,
18 },
15 object::GiteratedObject,
19 16 object_backend::ObjectBackend,
20 operation::{AnyOperation, GiteratedOperation},
17 operation::GiteratedOperation,
21 18 repository::{AccessList, Repository},
22 settings::{AnySetting, GetSetting, SetSetting, Setting},
19 settings::{GetSetting, SetSetting},
23 20 user::User,
24 value::{AnyValue, GetValue, GiteratedObjectValue},
21 value::{GetValue, GiteratedObjectValue},
25 22 };
26 23 use runtime::{GiteratedRuntime, GiteratedRuntimeState};
27 24 use serde::{de::DeserializeOwned, Serialize};
28 use serde_json::Value;
29 use state::HandlerState;
30 use tokio::{
31 sync::{mpsc::channel, Mutex},
32 task::JoinHandle,
33 };
34 use tracing::{error, warn};
35 use update::{
36 HandleSettingUpdate, HandleSettingUpdatedFunction, HandleValueUpdate,
37 HandleValueUpdatedFunction, SettingUpdateKind, ValueUpdateKind,
38 };
39 25
40 26 #[derive(Clone, Debug, Hash, Eq, PartialEq)]
41 27 struct ObjectOperationPair {
@@ -69,287 +55,12 @@ pub struct OperationMeta {
69 55 serialize_error: Box<dyn Fn(Box<dyn Any>) -> Result<Vec<u8>, serde_json::Error> + Send + Sync>,
70 56 }
71 57
72 // pub struct OperationHandlers<S: Send + Sync + Clone> {
73 // operations: HashMap<ObjectOperationPair, OperationWrapper<S>>,
74 // get_object: Vec<OperationWrapper<S>>,
75 // value_getters: HashMap<ValueGetter, OperationWrapper<S>>,
76 // settings_getter: HashMap<String, OperationWrapper<S>>,
77 // settings: HashMap<String, SettingMeta>,
78 // objects: HashMap<String, ObjectMeta>,
79 // operations_meta: HashMap<ObjectOperationPair, OperationMeta>,
80 // value_updated: HashMap<ValueUpdateKind, HandleValueUpdatedFunction>,
81 // setting_updated: HashMap<SettingUpdateKind, HandleSettingUpdatedFunction>,
82 // }
83
84 58 #[derive(Clone, Debug, Hash, Eq, PartialEq)]
85 59 pub struct ObjectValuePair {
86 60 pub object_kind: String,
87 61 pub value_kind: String,
88 62 }
89 63
90 // impl<S: Send + Sync + Clone> Default for OperationHandlers<S> {
91 // fn default() -> Self {
92 // Self {
93 // operations: HashMap::new(),
94 // get_object: Vec::new(),
95 // value_updated: HashMap::default(),
96 // setting_updated: HashMap::default(),
97 // value_getters: HashMap::default(),
98 // settings_getter: HashMap::default(),
99 // settings: HashMap::default(),
100 // objects: HashMap::default(),
101 // operations_meta: HashMap::default(),
102 // }
103 // }
104 // }
105
106 // impl<S: Send + Sync + Clone + 'static> OperationHandlers<S> {
107 // fn insert_operation<O: GiteratedObject, D: GiteratedOperation<O> + Send + Sync + 'static>(
108 // &mut self,
109 // ) {
110 // // let object_name = O::object_name().to_string();
111 // // let operation_name = D::operation_name().to_string();
112
113 // // self.operations_meta.insert(
114 // // ObjectOperationPair {
115 // // object_name: object_name.clone(),
116 // // operation_name: operation_name.clone(),
117 // // },
118 // // OperationMeta {
119 // // name: operation_name,
120 // // object_kind: object_name,
121 // // deserialize: Box::new(|bytes| {
122 // // Ok(Box::new(serde_json::from_slice::<D>(bytes).unwrap())
123 // // as Box<dyn Any + Send + Sync>)
124 // // }),
125 // // any_is_same: Box::new(|any_box| any_box.is::<D>()),
126 // // },
127 // // );
128 // }
129
130 // pub fn setting<T: Setting>(&mut self) -> &mut Self {
131 // let setting_meta = SettingMeta {
132 // name: T::name().to_string(),
133 // deserialize: Box::new(|slice| {
134 // Ok(Box::new(serde_json::from_slice(slice)?) as Box<dyn Any>)
135 // }),
136 // };
137
138 // self.settings.insert(T::name().to_string(), setting_meta);
139
140 // self
141 // }
142
143 // pub fn insert<
144 // A,
145 // O: GiteratedObject + Send + Sync + 'static,
146 // D: GiteratedOperation<O> + Send + Sync + 'static,
147 // H: GiteratedOperationHandler<A, O, D, S> + Send + Sync + 'static + Clone,
148 // >(
149 // &mut self,
150 // handler: H,
151 // ) -> &mut Self {
152 // let object_name = handler.object_name().to_string();
153 // let operation_name = handler.operation_name().to_string();
154
155 // let wrapped = OperationWrapper::new(handler);
156
157 // let pair = ObjectOperationPair {
158 // object_name,
159 // operation_name,
160 // };
161
162 // assert!(self.operations.insert(pair, wrapped).is_none());
163
164 // self.insert_operation::<O, D>();
165
166 // self
167 // }
168
169 // pub fn object<O: GiteratedObject + Send + Sync + 'static>(&mut self) -> &mut Self {
170 // // let object_meta = ObjectMeta {
171 // // name: O::object_name().to_string(),
172 // // from_str: Box::new(|str| Ok(Box::new(O::from_str(&str).map_err(|_| ())?))),
173
174 // // };
175
176 // // self.objects
177 // // .insert(O::object_name().to_string(), object_meta);
178
179 // let closure = |_: &Instance, operation: ObjectRequest, _state| {
180 // async move {
181 // if O::from_str(&operation.0).is_ok() {
182 // Ok(ObjectResponse(operation.0))
183 // } else {
184 // Err(OperationError::Unhandled)
185 // }
186 // }
187 // .boxed()
188 // };
189
190 // let wrapped = OperationWrapper::new(closure);
191
192 // self.get_object.push(wrapped);
193
194 // self
195 // }
196
197 // pub async fn handle<O: GiteratedObject>(
198 // &self,
199 // object: &O,
200 // operation_name: &str,
201 // operation: AnyOperation,
202 // state: S,
203 // operation_state: &StackOperationState,
204 // ) -> Result<Vec<u8>, OperationError<Vec<u8>>> {
205 // // TODO
206 // let object = object.to_string();
207 // let object_name = O::object_name().to_string();
208
209 // let object_meta = self
210 // .objects
211 // .get(&object_name)
212 // .ok_or_else(|| OperationError::Unhandled)?;
213
214 // let object_box = (object_meta.from_str)(&object).map_err(|_| OperationError::Unhandled)?;
215
216 // let target_handler = ObjectOperationPair {
217 // object_name,
218 // operation_name: operation_name.to_string(),
219 // };
220
221 // let operation_meta = self
222 // .operations_meta
223 // .get(&target_handler)
224 // .ok_or_else(|| OperationError::Unhandled)?;
225
226 // let operation_box =
227 // (operation_meta.deserialize)(&serde_json::to_vec(&operation.0).unwrap())
228 // .map_err(|_| OperationError::Unhandled)?;
229
230 // if let Some(handler) = self.operations.get(&target_handler) {
231 // handler
232 // .handle(object_box, operation_box, operation_state)
233 // .await
234 // } else {
235 // Err(OperationError::Unhandled)
236 // }
237 // }
238
239 // pub async fn resolve_object(
240 // &self,
241 // instance: Instance,
242 // request: ObjectRequest,
243 // state: S,
244 // operation_state: &StackOperationState,
245 // ) -> Result<Vec<u8>, OperationError<Vec<u8>>> {
246 // for handler in self.get_object.iter() {
247 // if let Ok(response) = handler
248 // .handle(
249 // Box::new(instance.clone()) as _,
250 // Box::new(request.clone()) as _,
251 // operation_state,
252 // )
253 // .await
254 // {
255 // return Ok(response);
256 // }
257 // }
258
259 // Err(OperationError::Unhandled)
260 // }
261
262 // pub fn insert_value_update_handler<
263 // H: HandleValueUpdate<O, V> + Send + Sync + Clone + 'static,
264 // O: GiteratedObject + Send + Sync,
265 // V: GiteratedObjectValue<Object = O> + Send + Sync,
266 // >(
267 // &mut self,
268 // handler: H,
269 // ) -> &mut Self {
270 // let wrapper = HandleValueUpdatedFunction::new(handler, V::value_name());
271
272 // assert!(self
273 // .value_updated
274 // .insert(wrapper.target.clone(), wrapper)
275 // .is_none());
276
277 // self
278 // }
279
280 // pub fn insert_setting_update_handler<
281 // H: HandleSettingUpdate<O, T> + Send + Sync + Clone + 'static,
282 // O: GiteratedObject + Send + Sync,
283 // T: Setting + Send + Sync,
284 // >(
285 // &mut self,
286 // handler: H,
287 // ) -> &mut Self {
288 // let wrapper = HandleSettingUpdatedFunction::new(handler, T::name());
289
290 // assert!(self
291 // .setting_updated
292 // .insert(wrapper.target.clone(), wrapper)
293 // .is_none());
294
295 // self
296 // }
297
298 // pub fn value_getter<A, O, V, F>(&mut self, handler: F) -> &mut Self
299 // where
300 // O: GiteratedObject + Send + Sync + 'static,
301 // V: GiteratedObjectValue<Object = O> + Send + Sync + 'static,
302 // F: GiteratedOperationHandler<A, O, GetValue<V>, S> + Send + Sync + Clone + 'static,
303 // {
304 // let object_name = handler.object_name().to_string();
305 // let value_name = V::value_name().to_string();
306
307 // let wrapped = OperationWrapper::new(handler);
308
309 // assert!(self
310 // .value_getters
311 // .insert(
312 // ValueGetter {
313 // object_type: object_name,
314 // value_type: value_name
315 // },
316 // wrapped
317 // )
318 // .is_none());
319
320 // self
321 // }
322
323 // pub fn setting_getter<A, O, F>(&mut self, handler: F) -> &mut Self
324 // where
325 // O: GiteratedObject + Send + Sync + 'static,
326 // F: GiteratedOperationHandler<A, O, GetSetting, S> + Send + Sync + Clone + 'static,
327 // {
328 // let object_name = handler.object_name().to_string();
329
330 // let wrapped = OperationWrapper::new(handler);
331
332 // assert!(self.settings_getter.insert(object_name, wrapped).is_none());
333
334 // self
335 // }
336 // }
337
338 #[derive(Clone, Debug, Hash, PartialEq, Eq)]
339 pub struct ValueGetter {
340 pub object_type: String,
341 pub value_type: String,
342 }
343
344 impl Default for ValueGetter {
345 fn default() -> Self {
346 Self {
347 object_type: AnyObject::object_name().to_string(),
348 value_type: "any".to_string(),
349 }
350 }
351 }
352
353 64 #[async_trait::async_trait]
354 65 pub trait GiteratedOperationHandler<
355 66 L,
@@ -987,156 +698,3 @@ impl Deref for AuthenticatedUser {
987 698 &self.0
988 699 }
989 700 }
990
991 #[derive(Clone)]
992 pub struct BackendWrapper {
993 sender: tokio::sync::mpsc::Sender<(
994 tokio::sync::oneshot::Sender<Result<Value, OperationError<Value>>>,
995 WrappedOperation,
996 )>,
997 task: Arc<JoinHandle<()>>,
998 }
999
1000 pub struct WrappedOperation {
1001 object: AnyObject,
1002 operation_payload: AnyOperation,
1003 operation_name: String,
1004 state: StackOperationState,
1005 }
1006
1007 // impl BackendWrapper {
1008 // pub fn new<S: HandlerState>(backend: GiteratedBackend<S>) -> Self {
1009 // // Spawn listener task
1010
1011 // let (send, mut recv) = channel::<(
1012 // tokio::sync::oneshot::Sender<Result<Value, OperationError<Value>>>,
1013 // WrappedOperation,
1014 // )>(1024);
1015
1016 // let task = tokio::spawn(async move {
1017 // while let Some((responder, message)) = recv.recv().await {
1018 // let raw_result = backend
1019 // .object_operation(
1020 // message.object,
1021 // &message.operation_name,
1022 // message.operation_payload,
1023 // &message.state,
1024 // )
1025 // .await;
1026
1027 // responder.send(raw_result).unwrap();
1028 // }
1029 // error!("Error, thing's dead");
1030 // });
1031
1032 // Self {
1033 // sender: send,
1034 // task: Arc::new(task),
1035 // }
1036 // }
1037
1038 // pub async fn call(&self, operation: WrappedOperation) -> Result<Value, OperationError<Value>> {
1039 // let (sender, response) = tokio::sync::oneshot::channel();
1040
1041 // self.sender
1042 // .send((sender, operation))
1043 // .await
1044 // .map_err(|e| OperationError::Internal(e.to_string()))?;
1045
1046 // match response.await {
1047 // Ok(result) => Ok(result?),
1048 // Err(err) => Err(OperationError::Internal(err.to_string())),
1049 // }
1050 // }
1051 // }
1052
1053 use std::fmt::Debug;
1054
1055 // #[async_trait::async_trait]
1056 // impl ObjectBackend<StackOperationState> for BackendWrapper {
1057 // async fn object_operation<O, D>(
1058 // &self,
1059 // object: O,
1060 // operation: &str,
1061 // payload: D,
1062 // operation_state: &StackOperationState,
1063 // ) -> Result<D::Success, OperationError<D::Failure>>
1064 // where
1065 // O: GiteratedObject + Debug,
1066 // D: GiteratedOperation<O> + Debug,
1067 // {
1068 // let operation = WrappedOperation {
1069 // object: AnyObject(object.to_string()),
1070 // operation_name: operation.to_string(),
1071 // operation_payload: AnyOperation(serde_json::to_value(payload).unwrap()),
1072 // state: operation_state.clone(),
1073 // };
1074
1075 // let raw_result = self.call(operation).await;
1076
1077 // match raw_result {
1078 // Ok(result) => Ok(serde_json::from_value(result)
1079 // .map_err(|e| OperationError::Internal(e.to_string()))?),
1080 // Err(err) => match err {
1081 // OperationError::Internal(internal) => {
1082 // warn!(
1083 // "Internal Error: {:?}",
1084 // OperationError::<()>::Internal(internal.clone())
1085 // );
1086
1087 // Err(OperationError::Internal(internal))
1088 // }
1089 // OperationError::Unhandled => Err(OperationError::Unhandled),
1090 // OperationError::Operation(err) => Err(OperationError::Operation(
1091 // serde_json::from_value(err)
1092 // .map_err(|e| OperationError::Internal(e.to_string()))?,
1093 // )),
1094 // },
1095 // }
1096 // }
1097
1098 // async fn get_object<O: GiteratedObject + Debug>(
1099 // &self,
1100 // object_str: &str,
1101 // operation_state: &StackOperationState,
1102 // ) -> Result<Object<StackOperationState, O, Self>, OperationError<ObjectRequestError>> {
1103 // let operation = WrappedOperation {
1104 // object: AnyObject(object_str.to_string()),
1105 // operation_name: ObjectRequest::operation_name().to_string(),
1106 // operation_payload: AnyOperation(
1107 // serde_json::to_value(ObjectRequest(object_str.to_string())).unwrap(),
1108 // ),
1109 // state: operation_state.clone(),
1110 // };
1111
1112 // let raw_result = self.call(operation).await;
1113
1114 // let object: ObjectResponse = match raw_result {
1115 // Ok(result) => Ok(serde_json::from_value(result)
1116 // .map_err(|e| OperationError::Internal(e.to_string()))?),
1117 // Err(err) => match err {
1118 // OperationError::Internal(internal) => {
1119 // warn!(
1120 // "Internal Error: {:?}",
1121 // OperationError::<()>::Internal(internal.clone())
1122 // );
1123
1124 // Err(OperationError::Internal(internal))
1125 // }
1126 // OperationError::Unhandled => Err(OperationError::Unhandled),
1127 // OperationError::Operation(err) => Err(OperationError::Operation(
1128 // serde_json::from_value(err)
1129 // .map_err(|e| OperationError::Internal(e.to_string()))?,
1130 // )),
1131 // },
1132 // }?;
1133
1134 // unsafe {
1135 // Ok(Object::new_unchecked(
1136 // O::from_str(&object.0)
1137 // .map_err(|_| OperationError::Internal("deserialize failure".to_string()))?,
1138 // self.clone(),
1139 // ))
1140 // }
1141 // }
1142 // }

giterated-stack/src/runtime.rs

View file
@@ -6,8 +6,8 @@ use giterated_models::{
6 6 message::GiteratedMessage,
7 7 object::{AnyObject, GiteratedObject, Object, ObjectRequestError},
8 8 object_backend::ObjectBackend,
9 operation::{AnyOperation, AnyOperationV2, GiteratedOperation},
10 settings::{AnySetting, GetSetting, SetSetting, Setting},
9 operation::{AnyOperationV2, GiteratedOperation},
10 settings::{GetSetting, SetSetting, Setting},
11 11 value::{GetValue, GetValueV2, GiteratedObjectValue},
12 12 };
13 13 use tracing::trace;
@@ -79,9 +79,9 @@ impl HandlerTree {
79 79
80 80 pub fn handle(
81 81 &self,
82 object: &dyn Any,
83 operation: Box<dyn Any>,
84 operation_state: &StackOperationState,
82 _object: &dyn Any,
83 _operation: Box<dyn Any>,
84 _operation_state: &StackOperationState,
85 85 ) -> Result<Box<dyn Any>, OperationError<Box<dyn Any>>> {
86 86 todo!()
87 87 }
@@ -370,7 +370,7 @@ where
370 370 &self,
371 371 object: &O,
372 372 operation: D,
373 state: S,
373 _state: S,
374 374 operation_state: &StackOperationState,
375 375 ) -> Result<D::Success, OperationError<D::Failure>> {
376 376 // Erase object and operation types.
@@ -451,7 +451,7 @@ impl GiteratedRuntime {
451 451 pub async fn handle_network_message<S: GiteratedRuntimeState>(
452 452 &self,
453 453 message: AuthenticatedPayload,
454 state: &S,
454 _state: &S,
455 455 operation_state: &StackOperationState,
456 456 ) -> Result<Vec<u8>, OperationError<Vec<u8>>> {
457 457 let message: GiteratedMessage<AnyObject, AnyOperationV2> = message.into_message_v2();
@@ -517,10 +517,10 @@ use core::fmt::Debug;
517 517 impl ObjectBackend<StackOperationState> for Arc<GiteratedRuntime> {
518 518 async fn object_operation<O, D>(
519 519 &self,
520 object: O,
521 operation: &str,
522 payload: D,
523 operation_state: &StackOperationState,
520 _object: O,
521 _operation: &str,
522 _payload: D,
523 _operation_state: &StackOperationState,
524 524 ) -> Result<D::Success, OperationError<D::Failure>>
525 525 where
526 526 O: GiteratedObject + Debug + 'static,
@@ -531,8 +531,8 @@ impl ObjectBackend<StackOperationState> for Arc<GiteratedRuntime> {
531 531
532 532 async fn get_object<O: GiteratedObject + Debug>(
533 533 &self,
534 object_str: &str,
535 operation_state: &StackOperationState,
534 _object_str: &str,
535 _operation_state: &StackOperationState,
536 536 ) -> Result<Object<StackOperationState, O, Self>, OperationError<ObjectRequestError>> {
537 537 todo!()
538 538 }

giterated-stack/src/update.rs

View file
@@ -1,5 +1,3 @@
1 use std::sync::Arc;
2
3 1 use futures_util::{future::BoxFuture, FutureExt};
4 2 use giterated_models::{
5 3 object::GiteratedObject,
@@ -129,7 +127,7 @@ impl HandleSettingUpdatedFunction {
129 127
130 128 let setting: S = serde_json::from_value(value.0).unwrap();
131 129
132 handler
130 let _ = handler
133 131 .handle_setting_update(object, setting_name, setting, &state)
134 132 .await;
135 133
@@ -181,7 +179,7 @@ impl HandleValueUpdatedFunction {
181 179
182 180 let setting: V = serde_json::from_value(value.0).unwrap();
183 181
184 handler
182 let _ = handler
185 183 .handle_value_update(object, setting_name, setting, &state)
186 184 .await;
187 185