diff --git a/nativelink-scheduler/src/operation_state_manager.rs b/nativelink-scheduler/src/operation_state_manager.rs index 75e966991..7baa5f156 100644 --- a/nativelink-scheduler/src/operation_state_manager.rs +++ b/nativelink-scheduler/src/operation_state_manager.rs @@ -43,6 +43,9 @@ pub trait ActionStateResult: Send + Sync + 'static { async fn as_state(&self) -> Result, Error>; // Subscribes to the state of the action, receiving updates as they are published. async fn as_receiver(&self) -> Result<&'_ watch::Receiver>, Error>; + // Provide result as action info. This behavior will not be supported by all implementations. + // TODO(adams): Expectation is this to experimental and removed in the future. + async fn as_action_info(&self) -> Result, Error>; } /// The filters used to query operations from the state manager. @@ -70,8 +73,26 @@ pub struct OperationFilter { /// The operation must have it's last client update before this time. pub last_client_update_before: Option, - /* Why is this now not optional?*/ + /// The unique key for filtering specific action results. pub unique_qualifier: Option, + + /// The order by in which results are returned by the filter operation. + pub order_by: Option, +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub enum OperationFields { + Priority, + Timestamp, +} + +/// The order in which results are returned by the filter operation. +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct OrderBy { + /// The fields to order by, each field is ordered in the order they are provided. + pub fields: Vec, + /// The order of the fields, true for descending, false for ascending. + pub desc: bool, } pub type ActionStateResultStream = Pin> + Send>>;