@@ -24,7 +24,6 @@ use anyhow::{Context, Result, anyhow};
2424use parking_lot:: RwLock ;
2525use std:: collections:: HashMap ;
2626use std:: sync:: { Arc , OnceLock } ;
27- use std:: time:: { SystemTime , UNIX_EPOCH } ;
2827
2928type SharedTask = Arc < RwLock < Box < dyn TaskLifecycle > > > ;
3029type TaskMap = Arc < RwLock < HashMap < String , SharedTask > > > ;
@@ -87,7 +86,12 @@ impl TaskManager {
8786
8887impl TaskManager {
8988 pub fn register_task ( & self , config_bytes : & [ u8 ] , module_bytes : & [ u8 ] ) -> Result < ( ) > {
90- let task = TaskBuilder :: from_yaml_config ( config_bytes, module_bytes)
89+ use std:: time:: { SystemTime , UNIX_EPOCH } ;
90+ let create_time = SystemTime :: now ( )
91+ . duration_since ( UNIX_EPOCH )
92+ . unwrap ( )
93+ . as_secs ( ) ;
94+ let task = TaskBuilder :: from_yaml_config ( config_bytes, module_bytes, create_time)
9195 . map_err ( |e| anyhow ! ( "Failed to build task: {}" , e) ) ?;
9296 let info = task. get_function_info ( ) ;
9397 let task_info = StoredTaskInfo {
@@ -96,10 +100,7 @@ impl TaskManager {
96100 module_bytes : Some ( TaskModuleBytes :: Wasm ( module_bytes. to_vec ( ) ) ) ,
97101 config_bytes : config_bytes. to_vec ( ) ,
98102 state : ComponentState :: Initialized ,
99- created_at : SystemTime :: now ( )
100- . duration_since ( UNIX_EPOCH )
101- . unwrap ( )
102- . as_secs ( ) ,
103+ created_at : info. create_time ,
103104 checkpoint_id : None ,
104105 } ;
105106 self . register_task_internal ( task, Some ( task_info) )
@@ -112,7 +113,12 @@ impl TaskManager {
112113 ) -> Result < ( ) > {
113114 #[ cfg( feature = "python" ) ]
114115 {
115- let task = TaskBuilder :: from_python_config ( config_bytes, modules)
116+ use std:: time:: { SystemTime , UNIX_EPOCH } ;
117+ let create_time = SystemTime :: now ( )
118+ . duration_since ( UNIX_EPOCH )
119+ . unwrap ( )
120+ . as_secs ( ) ;
121+ let task = TaskBuilder :: from_python_config ( config_bytes, modules, create_time)
116122 . map_err ( |e| anyhow ! ( "Failed to build Python task: {}" , e) ) ?;
117123 let ( class_name, module_name, module_bytes) = match modules. first ( ) {
118124 Some ( ( name, bytes) ) => ( name. clone ( ) , name. clone ( ) , Some ( bytes. clone ( ) ) ) ,
@@ -129,10 +135,7 @@ impl TaskManager {
129135 } ) ,
130136 config_bytes : config_bytes. to_vec ( ) ,
131137 state : ComponentState :: Initialized ,
132- created_at : SystemTime :: now ( )
133- . duration_since ( UNIX_EPOCH )
134- . unwrap ( )
135- . as_secs ( ) ,
138+ created_at : info. create_time ,
136139 checkpoint_id : None ,
137140 } ;
138141 self . register_task_internal ( task, Some ( task_info) )
@@ -288,10 +291,12 @@ impl TaskManager {
288291 return Ok ( ( ) ) ;
289292 }
290293
294+ let create_time = stored. created_at ;
295+
291296 let task = match & stored. module_bytes {
292- None => TaskBuilder :: from_yaml_config ( & stored. config_bytes , & [ ] ) ,
297+ None => TaskBuilder :: from_yaml_config ( & stored. config_bytes , & [ ] , create_time ) ,
293298 Some ( TaskModuleBytes :: Wasm ( bytes) ) => {
294- TaskBuilder :: from_yaml_config ( & stored. config_bytes , bytes)
299+ TaskBuilder :: from_yaml_config ( & stored. config_bytes , bytes, create_time )
295300 }
296301 Some ( TaskModuleBytes :: Python {
297302 class_name : _,
@@ -301,7 +306,7 @@ impl TaskManager {
301306 #[ cfg( feature = "python" ) ]
302307 {
303308 let modules = [ ( module. clone ( ) , py_bytes. clone ( ) . unwrap_or_default ( ) ) ] ;
304- TaskBuilder :: from_python_config ( & stored. config_bytes , & modules)
309+ TaskBuilder :: from_python_config ( & stored. config_bytes , & modules, create_time )
305310 }
306311 #[ cfg( not( feature = "python" ) ) ]
307312 {
0 commit comments