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