@@ -30,6 +30,7 @@ use codederror::CodedError;
3030use restate_core:: { Metadata , TaskCenter } ;
3131use restate_invoker_api:: StatusHandle ;
3232use restate_partition_store:: PartitionStoreManager ;
33+ use restate_sharding:: KeyRange ;
3334use restate_types:: cluster:: cluster_state:: LegacyClusterState ;
3435use restate_types:: config:: QueryEngineOptions ;
3536use restate_types:: errors:: GenericError ;
@@ -39,6 +40,7 @@ use restate_types::partition_table::Partition;
3940use restate_types:: partitions:: state:: PartitionReplicaSetStates ;
4041use restate_types:: schema:: deployment:: DeploymentResolver ;
4142use restate_types:: schema:: service:: ServiceMetadataResolver ;
43+ use restate_worker_api:: SchedulerStatusEntry ;
4244
4345use crate :: node_fan_out:: NodeWarnings ;
4446use crate :: remote_query_scanner_manager:: RemoteScannerManager ;
@@ -130,6 +132,28 @@ pub trait RegisterTable: Send + Sync + 'static {
130132 fn register ( & self , ctx : & QueryContext ) -> impl Future < Output = Result < ( ) , BuildError > > ;
131133}
132134
135+ /// A leader-state introspection handle that extends invoker status queries with
136+ /// additional query methods for future leader-owned components.
137+ pub trait PartitionLeaderStatusHandle :
138+ StatusHandle + Send + Sync + Debug + Clone + ' static
139+ {
140+ type SchedulerStatus ;
141+ type SchedulerStatusIterator : Iterator < Item = Self :: SchedulerStatus > + Send ;
142+
143+ type UserLimitCounter ;
144+ type UserLimitCounterIterator : Iterator < Item = Self :: UserLimitCounter > + Send ;
145+
146+ fn read_scheduler_status (
147+ & self ,
148+ keys : KeyRange ,
149+ ) -> impl Future < Output = Self :: SchedulerStatusIterator > + Send ;
150+
151+ fn read_user_limit_counters (
152+ & self ,
153+ keys : KeyRange ,
154+ ) -> impl Future < Output = Self :: UserLimitCounterIterator > + Send ;
155+ }
156+
133157/// A no-op registerer that creates a minimal query context with no tables.
134158/// Useful for nodes that only need to serve remote scanner RPCs (e.g.,
135159/// log-server-only nodes), where only `task_ctx()` is needed.
@@ -145,7 +169,7 @@ impl RegisterTable for NoTables {
145169pub struct UserTables < P , S , D > {
146170 partition_selector : P ,
147171 partition_store_manager : Arc < PartitionStoreManager > ,
148- status : Option < S > ,
172+ partition_leader_status : Option < S > ,
149173 schemas : Live < D > ,
150174 remote_scanner_manager : RemoteScannerManager ,
151175}
@@ -154,14 +178,14 @@ impl<P, S, D> UserTables<P, S, D> {
154178 pub fn new (
155179 partition_selector : P ,
156180 partition_store_manager : Arc < PartitionStoreManager > ,
157- status : Option < S > ,
181+ partition_leader_status : Option < S > ,
158182 schemas : Live < D > ,
159183 remote_scanner_manager : RemoteScannerManager ,
160184 ) -> Self {
161185 Self {
162186 partition_selector,
163187 partition_store_manager,
164- status ,
188+ partition_leader_status ,
165189 schemas,
166190 remote_scanner_manager,
167191 }
@@ -171,7 +195,7 @@ impl<P, S, D> UserTables<P, S, D> {
171195impl < P , S , D > RegisterTable for UserTables < P , S , D >
172196where
173197 P : SelectPartitions + Clone ,
174- S : StatusHandle + Send + Sync + Debug + Clone + ' static ,
198+ S : PartitionLeaderStatusHandle < SchedulerStatus = SchedulerStatusEntry > ,
175199 D : DeploymentResolver + ServiceMetadataResolver + Send + Sync + Debug + Clone + ' static ,
176200{
177201 async fn register ( & self , ctx : & QueryContext ) -> Result < ( ) , BuildError > {
@@ -182,7 +206,7 @@ where
182206 crate :: invocation_state:: register_self (
183207 ctx,
184208 self . partition_selector . clone ( ) ,
185- self . status . clone ( ) ,
209+ self . partition_leader_status . clone ( ) ,
186210 self . partition_store_manager . clone ( ) ,
187211 & self . remote_scanner_manager ,
188212 ) ?;
@@ -350,7 +374,9 @@ impl QueryContext {
350374 options : & QueryEngineOptions ,
351375 partition_selector : impl SelectPartitions + Clone ,
352376 partition_store_manager : Arc < PartitionStoreManager > ,
353- status : Option < impl StatusHandle + Send + Sync + Debug + Clone + ' static > ,
377+ partition_leader_status : Option <
378+ impl PartitionLeaderStatusHandle < SchedulerStatus = SchedulerStatusEntry > ,
379+ > ,
354380 schemas : Live <
355381 impl DeploymentResolver + ServiceMetadataResolver + Send + Sync + Debug + Clone + ' static ,
356382 > ,
@@ -359,7 +385,7 @@ impl QueryContext {
359385 let tables = UserTables :: new (
360386 partition_selector,
361387 partition_store_manager,
362- status ,
388+ partition_leader_status ,
363389 schemas,
364390 remote_scanner_manager,
365391 ) ;
0 commit comments