@@ -21,15 +21,18 @@ pub struct RouterRequest {
2121 pub tokens : Vec < Token > ,
2222}
2323
24+ /// Identifier of a LLM worker which emits events to the router.
25+ pub type WorkerId = i64 ;
26+
2427#[ derive( Debug , Clone , Serialize , Deserialize , Default ) ]
2528pub struct RouterResponse {
26- pub worker_id : i64 ,
29+ pub worker_id : WorkerId ,
2730}
2831
2932#[ derive( Debug ) ]
3033pub struct WorkerSelectionResult {
3134 /// The worker id of the selected worker
32- pub worker_id : i64 ,
35+ pub worker_id : WorkerId ,
3336
3437 /// The total number of blocks required to prefill the request
3538 pub required_blocks : u64 ,
@@ -58,14 +61,14 @@ pub struct ForwardPassMetrics {
5861
5962/// A [`LocalBlockHash`] is a hash computed from the tokens_ids, extra_token_ids and the optional
6063/// lora_id of a block.
61- #[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash , Ord , PartialOrd ) ]
64+ #[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash ) ]
6265pub struct LocalBlockHash ( pub u64 ) ;
6366
6467/// A sequence aware hash of a block where the hash is computed from the tokens_ids, extra_token_ids
6568/// and the optional lora_id of a block, PLUS the hash of the parent block.
6669///
6770/// In this case, the hashing function is external and unknown.
68- #[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash , Ord , PartialOrd ) ]
71+ #[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash ) ]
6972pub struct ExternalSequenceBlockHash ( pub u64 ) ;
7073
7174// Implement From trait for convenient conversion
@@ -138,6 +141,31 @@ pub struct KvCacheRemoveData {
138141 pub block_hashes : Vec < ExternalSequenceBlockHash > ,
139142}
140143
144+ /// A [`KvCacheEvent`] on a specific LLM worker denoted by [`WorkerId`].
145+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
146+ pub struct RouterEvent {
147+ /// The ID of the worker emitting the event.
148+ pub worker_id : WorkerId ,
149+ /// The cache event associated with the worker.
150+ pub event : KvCacheEvent ,
151+ }
152+
153+ impl RouterEvent {
154+ /// Create a new `RouterEvent`.
155+ ///
156+ /// ### Arguments
157+ ///
158+ /// * `worker_id` - The ID of the worker emitting the event.
159+ /// * `event` - The cache event.
160+ ///
161+ /// ### Returns
162+ ///
163+ /// A new `RouterEvent`.
164+ pub fn new ( worker_id : WorkerId , event : KvCacheEvent ) -> Self {
165+ Self { worker_id, event }
166+ }
167+ }
168+
141169impl Serialize for LocalBlockHash {
142170 fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
143171 where
0 commit comments