1- use crate :: { WorkerClient , abstractions :: dbg_panic } ;
2- use gethostname :: gethostname ;
1+ use crate :: WorkerClient ;
2+ use crate :: worker :: { TaskPollers , WorkerTelemetry } ;
33use parking_lot:: Mutex ;
44use prost_types:: Duration as PbDuration ;
5- use std:: { fmt, sync:: { Arc , OnceLock } , time:: { Duration , SystemTime } } ;
65use std:: collections:: HashMap ;
7- use temporal_sdk_core_api:: worker:: { WorkerConfig , WorkerConfigBuilder , WorkerVersioningStrategy } ;
8- use temporal_sdk_core_protos:: temporal:: api:: worker:: v1:: { WorkerHeartbeat , WorkerHostInfo } ;
9- use tokio:: { sync:: Notify , task:: JoinHandle , time:: MissedTickBehavior } ;
10- use uuid:: Uuid ;
6+ use std:: {
7+ fmt,
8+ sync:: Arc ,
9+ time:: { Duration , SystemTime } ,
10+ } ;
1111use temporal_client:: SharedNamespaceWorkerTrait ;
12- use crate :: worker:: { TaskPollers , WorkerTelemetry } ;
12+ use temporal_sdk_core_api:: worker:: { WorkerConfigBuilder , WorkerVersioningStrategy } ;
13+ use temporal_sdk_core_protos:: temporal:: api:: worker:: v1:: WorkerHeartbeat ;
14+ use tokio:: sync:: Notify ;
1315
1416/// Callback used to collect heartbeat data from each worker at the time of heartbeat
1517pub ( crate ) type HeartbeatFn = Box < dyn Fn ( ) -> WorkerHeartbeat + Send + Sync > ;
@@ -29,12 +31,16 @@ impl SharedNamespaceWorker {
2931 heartbeat_interval : Duration ,
3032 telemetry : Option < WorkerTelemetry > ,
3133 ) -> Self {
32- println ! ( "SharedNamespaceWorker::new() {:?}\n \t sdk_name_and_version key{:?}" , client. get_identity( ) , client. sdk_name_and_version( ) ) ;
34+ println ! (
35+ "SharedNamespaceWorker::new() {:?}\n \t sdk_name_and_version key{:?}" ,
36+ client. get_identity( ) ,
37+ client. sdk_name_and_version( )
38+ ) ;
3339 let config = WorkerConfigBuilder :: default ( )
3440 . namespace ( namespace. clone ( ) )
3541 . task_queue ( format ! (
3642 "temporal-sys/worker-commands/{namespace}/{}" ,
37- client. get_process_key( ) . to_string ( )
43+ client. get_process_key( )
3844 ) )
3945 . no_remote_activities ( true )
4046 . max_outstanding_nexus_tasks ( 5_usize )
@@ -68,7 +74,9 @@ impl SharedNamespaceWorker {
6874 loop {
6975 // TODO: Race condition here, can technically shut down before anything is ever initialized
7076 if heartbeat_map_clone. lock ( ) . is_empty ( ) {
71- println ! ( "// TODO: Race condition here, can technically shut down before anything is ever initialized" ) ;
77+ println ! (
78+ "// TODO: Race condition here, can technically shut down before anything is ever initialized"
79+ ) ;
7280 worker. shutdown ( ) . await ;
7381 return ;
7482 }
@@ -174,11 +182,15 @@ mod tests {
174182 worker,
175183 worker:: client:: mocks:: mock_worker_client,
176184 } ;
177- use std:: { sync:: { Arc , atomic:: { AtomicUsize , Ordering } } , time:: Duration } ;
178- use mockall:: mock;
185+ use std:: {
186+ sync:: {
187+ Arc ,
188+ atomic:: { AtomicUsize , Ordering } ,
189+ } ,
190+ time:: Duration ,
191+ } ;
179192 use temporal_sdk_core_api:: worker:: PollerBehavior ;
180193 use temporal_sdk_core_protos:: temporal:: api:: workflowservice:: v1:: RecordWorkerHeartbeatResponse ;
181- use uuid:: Uuid ;
182194
183195 #[ tokio:: test]
184196 async fn worker_heartbeat_basic ( ) {
@@ -217,7 +229,13 @@ mod tests {
217229 . into ( ) ;
218230
219231 let client = Arc :: new ( mock) ;
220- let worker = worker:: Worker :: new ( config, None , client. clone ( ) , None , Some ( Duration :: from_millis ( 100 ) ) ) ;
232+ let worker = worker:: Worker :: new (
233+ config,
234+ None ,
235+ client. clone ( ) ,
236+ None ,
237+ Some ( Duration :: from_millis ( 100 ) ) ,
238+ ) ;
221239
222240 tokio:: time:: sleep ( Duration :: from_millis ( 250 ) ) . await ;
223241 worker. drain_activity_poller_and_shutdown ( ) . await ;
0 commit comments