@@ -7,6 +7,7 @@ use slotmap::SlotMap;
77use std:: collections:: { HashMap , hash_map:: Entry :: Vacant } ;
88use temporal_sdk_core_protos:: temporal:: api:: worker:: v1:: WorkerHeartbeat ;
99use temporal_sdk_core_protos:: temporal:: api:: workflowservice:: v1:: PollWorkflowTaskQueueResponse ;
10+ use uuid:: Uuid ;
1011
1112slotmap:: new_key_type! {
1213 /// Registration key for a worker
@@ -131,12 +132,15 @@ pub trait SharedNamespaceWorkerTrait: std::fmt::Debug {
131132}
132133
133134/// Enables local workers to make themselves visible to a shared client instance.
134- /// There can only be one worker registered per namespace+queue_name+client, others will get ignored.
135+ ///
136+ /// For slot managing, there can only be one worker registered per
137+ /// namespace+queue_name+client, others will get ignored.
135138/// It also provides a convenient method to find compatible slots within the collection.
136139#[ derive( Default , Debug ) ]
137140pub struct ClientWorkerSet {
138141 slot_manager : RwLock < SlotManagerImpl > ,
139142 heartbeat_manager : Mutex < HashMap < String , Box < dyn SharedNamespaceWorkerTrait + Send + Sync > > > ,
143+ worker_set_key : Uuid ,
140144}
141145
142146impl ClientWorkerSet {
@@ -145,6 +149,7 @@ impl ClientWorkerSet {
145149 Self {
146150 slot_manager : RwLock :: new ( SlotManagerImpl :: new ( ) ) ,
147151 heartbeat_manager : Mutex :: new ( HashMap :: new ( ) ) ,
152+ worker_set_key : Uuid :: new_v4 ( ) ,
148153 }
149154 }
150155
@@ -208,6 +213,11 @@ impl ClientWorkerSet {
208213 }
209214 }
210215
216+ /// Returns the worker set key, which is unique for each client. Used for worker heartbeating
217+ pub fn worker_set_key ( & self ) -> Uuid {
218+ self . worker_set_key
219+ }
220+
211221 #[ cfg( test) ]
212222 /// Returns (num_providers, num_buckets), where a bucket key is namespace+task_queue.
213223 /// There is only one provider per bucket so `num_providers` should be equal to `num_buckets`.
0 commit comments