Set up the daemon for the plugin architecture
parent: tbd commit: d046615
1 | use Arc; |
2 | |
3 | use ; |
4 | use |
5 | , |
6 | , | Instance
7 | , | ObjectBackend
8 | ; |
9 | use ; |
10 | use |
11 | , |
12 | AuthenticatedPayload, StackOperationState, |
13 | ; |
14 | use TcpStream; |
15 | use ; |
16 | |
17 | pub async |
18 | our_instance: Instance, |
19 | mut socket: , |
20 | runtime: , |
21 | |
22 | loop |
23 | let message = socket.next .await; |
24 | |
25 | if message.is_none |
26 | // Keep an eye out for this, I dont see why we shouldn't end the connection |
27 | unreachable! |
28 | |
29 | |
30 | let message = message.unwrap; |
31 | |
32 | let payload = match message |
33 | Ok => |
34 | let payload = match message |
35 | => payload, | Binary
36 | => | Ping
37 | let _ = socket.send .await; |
38 | continue; |
39 | |
40 | => return, | Close
41 | _ => continue, |
42 | ; |
43 | |
44 | payload |
45 | |
46 | Err => |
47 | // Connection error |
48 | warn!; |
49 | |
50 | return; |
51 | |
52 | ; |
53 | |
54 | trace!; |
55 | |
56 | let payload = match |
57 | Ok => payload, |
58 | Err => |
59 | warn! |
60 | "A network payload deserialization failure has occurred: {:?}", |
61 | e |
62 | ; |
63 | |
64 | continue; |
65 | |
66 | ; |
67 | |
68 | trace! |
69 | "Deserialized payload for operation {} from client", |
70 | payload.operation |
71 | ; |
72 | |
73 | todo! |
74 | |
75 | // let operation_state = StackOperationState { |
76 | // our_instance: our_instance.clone(), |
77 | // instance: None, |
78 | // user: None, |
79 | // }; |
80 | |
81 | // let result = handle_client_message(payload, operation_state, runtime.clone()).await; |
82 | |
83 | // Grab operation errors so we can log them, they don't make it across the network |
84 | // if let Err(OperationError::Internal(internal_error)) = &result { |
85 | // error!("An internal error has occurred:\n{:?}", internal_error); |
86 | // } |
87 | |
88 | // // Map error to the network variant |
89 | // let result = result.map_err(|e| e.into_network()); |
90 | |
91 | // socket |
92 | // .send(Message::Binary(bincode::serialize(&result).unwrap())) |
93 | // .await |
94 | // .expect("there was an error sending a message, this is a problem for the receiver"); |
95 | |
96 | |
97 | |
98 | pub async |
99 | payload: AuthenticatedPayload, |
100 | operation_state: StackOperationState, |
101 | runtime: RuntimeHandle, |
102 | |
103 | let mut networked_object = runtime |
104 | . |
105 | .await |
106 | .as_internal_error_with_context?; |
107 | |
108 | let message: GiteratedMessage = |
109 | payload.into_message; |
110 | |
111 | let networked_operation = new |
112 | message.payload.name.clone, |
113 | message.payload.payload.clone, |
114 | ; |
115 | |
116 | trace!; |
117 | |
118 | networked_object |
119 | .request |
120 | .await |
121 | |
122 |