@@ -172,3 +172,63 @@ impl TaskMessage {
172
172
}
173
173
}
174
174
}
175
+
176
+ #[ derive( Debug , Clone , PartialEq ) ]
177
+ pub struct TaskState {
178
+ pub is_succeeded : bool ,
179
+ }
180
+
181
+ #[ derive( Debug , Clone , Copy , PartialEq ) ]
182
+ pub enum DependentType {
183
+ After = 0 ,
184
+ Before = 1 ,
185
+ }
186
+
187
+ #[ derive( Debug , Clone , PartialEq ) ]
188
+ pub struct TaskDependent {
189
+ pub ty : DependentType ,
190
+ pub source : String ,
191
+ pub target : String ,
192
+ }
193
+
194
+ impl TaskDependent {
195
+ pub fn new ( ty : DependentType , source : String , target : String ) -> Self {
196
+ Self { ty, source, target }
197
+ }
198
+ }
199
+
200
+ mod kvapi_key_impl {
201
+ use databend_common_meta_kvapi:: kvapi;
202
+ use databend_common_meta_kvapi:: kvapi:: KeyError ;
203
+
204
+ use crate :: principal:: DependentType ;
205
+ use crate :: principal:: TaskDependent ;
206
+
207
+ impl kvapi:: KeyCodec for TaskDependent {
208
+ fn encode_key ( & self , b : kvapi:: KeyBuilder ) -> kvapi:: KeyBuilder {
209
+ match self . ty {
210
+ DependentType :: After => b. push_str ( "After" ) ,
211
+ DependentType :: Before => b. push_str ( "Before" ) ,
212
+ }
213
+ . push_str ( self . source . as_str ( ) )
214
+ . push_str ( self . target . as_str ( ) )
215
+ }
216
+
217
+ fn decode_key ( parser : & mut kvapi:: KeyParser ) -> Result < Self , kvapi:: KeyError > {
218
+ let ty = match parser. next_str ( ) ?. as_str ( ) {
219
+ "After" => DependentType :: After ,
220
+ "Before" => DependentType :: Before ,
221
+ str => {
222
+ return Err ( KeyError :: InvalidId {
223
+ s : str. to_string ( ) ,
224
+ reason : "Invalid Dependent Type" . to_string ( ) ,
225
+ } )
226
+ }
227
+ } ;
228
+ let source = parser. next_str ( ) ?;
229
+ let target = parser. next_str ( ) ?;
230
+
231
+ Ok ( Self { ty, source, target } )
232
+ }
233
+ }
234
+ }
0 commit comments