Huge refactor to prep for moving the daemon over to the plugin architecture
parent: tbd commit: 5df753c
1 | use ; |
2 | |
3 | use Error; |
4 | use ; |
5 | use |
6 | , |
7 | , | Instance
8 | , | GiteratedObject
9 | , | GiteratedOperation
10 | ; |
11 | use |
12 | , |
13 | AnyFailure, AnyObject, AnyOperation, AnySuccess, |
14 | ; |
15 | use ; |
16 | use TcpStream; |
17 | use ; |
18 | |
19 | use crate::; |
20 | |
21 | pub async |
22 | state: ProtocolState, |
23 | object: NetworkedObject, |
24 | operation: NetworkedOperation, |
25 | runtime: RuntimeHandle, |
26 | |
27 | trace!; |
28 | |
29 | runtime |
30 | .handle_serialized |
31 | .await |
32 | |
33 | |
34 | |
35 | ; |
36 | |
37 | |
38 | type Err = ; |
39 | |
40 | |
41 | Ok |
42 | |
43 | |
44 | |
45 | |
46 | |
47 | f.write_str |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | "networked_object" |
54 | |
55 | |
56 | |
57 | todo! |
58 | |
59 | |
60 | |
61 | todo! |
62 | |
63 | |
64 | |
65 | |
66 | |
67 | pub name: String, |
68 | pub payload: , |
69 | |
70 | |
71 | |
72 | |
73 | Self |
74 | |
75 | |
76 | |
77 | |
78 | type Success = ; |
79 | |
80 | type Failure = ; |
81 | |
82 | |
83 | "networked_operation" |
84 | |
85 | |
86 | |
87 | /// Handler which will attempt to resolve any operation that doesn't resolve locally |
88 | /// against a remote instance. |
89 | pub async |
90 | state: ProtocolState, |
91 | object: AnyObject, |
92 | operation: AnyOperation, |
93 | |
94 | // if object.is::<NetworkedObject>() { |
95 | // return Err(OperationError::Unhandled); |
96 | // } |
97 | // trace!( |
98 | // "Try handling object operation {}::{} with remote", |
99 | // object.kind(), |
100 | // operation.kind().operation_name |
101 | // ); |
102 | // TODO: |
103 | // Ideally we support pass-through on object types that aren't used locally. |
104 | // For now, we aren't worrying about that. |
105 | let object_meta = object.vtable .clone; |
106 | |
107 | let operation_meta = operation.vtable .clone; |
108 | |
109 | // trace!( |
110 | // "Serializing with {}::{}", |
111 | // operation.kind().object_name, |
112 | // operation.kind().operation_name |
113 | // ); |
114 | |
115 | let object_home_uri = unsafe ; |
116 | |
117 | if let Some = state.home_uri |
118 | if &home_uri == object_home_uri.as_ref |
119 | // This isn't a remote request, requests aren't supposed to hit this layer |
120 | // if they're not remote. |
121 | // warn!("Try handling object operation {}::{}, resolved object home uri as local home uri. This is a bug.", object.kind(), |
122 | // operation.kind().operation_name); |
123 | |
124 | return Err; |
125 | |
126 | |
127 | |
128 | // trace!( |
129 | // "Handling object operation {}::{} sending payload", |
130 | // object.kind(), |
131 | // operation.kind().operation_name |
132 | // ); |
133 | |
134 | let object = NetworkedObject; |
135 | |
136 | let payload = unsafe .unwrap; |
137 | let payload = Vec from; |
138 | |
139 | let operation = new; |
140 | |
141 | // let authenticated = Authenticated::new(object, operation); |
142 | |
143 | let message = GiteratedMessage |
144 | object, |
145 | operation: operation_name .to_string, |
146 | payload: operation, |
147 | ; |
148 | |
149 | let authenticated = new; |
150 | |
151 | let mut socket: = connect_to |
152 | & from_str .unwrap, |
153 | &Some, |
154 | |
155 | .await |
156 | .unwrap; |
157 | |
158 | // TODO AUTH |
159 | |
160 | let result: = |
161 | send_expect .await; |
162 | |
163 | match result |
164 | Ok => |
165 | let success = unsafe .unwrap; |
166 | |
167 | Ok |
168 | |
169 | Err => Err |
170 | => | Operation
171 | let failure = unsafe .unwrap; |
172 | |
173 | Operation |
174 | |
175 | => Internal, | Internal
176 | => Unhandled, | Unhandled
177 | , |
178 | |
179 | |
180 | |
181 | type Socket = ; |
182 | |
183 | async |
184 | instance: &Instance, |
185 | |
186 | socket_addr: & , |
187 | |
188 | if let Some = socket_addr |
189 | info! |
190 | "Connecting to {}", |
191 | format! |
192 | ; |
193 | |
194 | let = |
195 | connect_async .await?; |
196 | |
197 | info!; |
198 | |
199 | Ok |
200 | else |
201 | info! |
202 | "Connecting to {}", |
203 | format! |
204 | ; |
205 | |
206 | let = |
207 | connect_async .await?; |
208 | |
209 | info!; |
210 | |
211 | Ok |
212 | |
213 | |
214 | |
215 | async |
216 | socket: &mut Socket, |
217 | message: , |
218 | |
219 | let payload = serialize .unwrap; |
220 | |
221 | socket.send .await.unwrap; |
222 | |
223 | while let Some = socket.next .await |
224 | let payload = match message.unwrap |
225 | => payload, | Binary
226 | |
227 | _ => |
228 | continue; |
229 | |
230 | ; |
231 | |
232 | let raw_result = |
233 | |
234 | .map_err?; |
235 | |
236 | trace! |
237 | "Received response for networked operation {}::{}.", |
238 | , | object_name
239 | operation_name |
240 | ; |
241 | |
242 | return match raw_result |
243 | Ok => Ok, |
244 | Err => Err |
245 | => | Operation
246 | Operation |
247 | |
248 | => Internal, | Internal
249 | => Unhandled, | Unhandled
250 | , |
251 | ; |
252 | |
253 | |
254 | panic! |
255 | |
256 |