From 4c519c2ab3db032b525d57117b95a76b2a5e8517 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Mon, 9 Jan 2023 09:33:44 +0100 Subject: [PATCH] Add Batch::index_uid --- index-scheduler/src/batch.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/index-scheduler/src/batch.rs b/index-scheduler/src/batch.rs index 8a479a12b..50225ff82 100644 --- a/index-scheduler/src/batch.rs +++ b/index-scheduler/src/batch.rs @@ -169,6 +169,22 @@ impl Batch { Batch::IndexSwap { task } => vec![task.uid], } } + + /// Return the index UID associated with this batch + pub fn index_uid(&self) -> Option<&str> { + use Batch::*; + match self { + TaskCancelation { .. } + | TaskDeletion(_) + | SnapshotCreation(_) + | Dump(_) + | IndexSwap { .. } => None, + IndexOperation { op, .. } => Some(op.index_uid()), + IndexCreation { index_uid, .. } + | IndexUpdate { index_uid, .. } + | IndexDeletion { index_uid, .. } => Some(index_uid), + } + } } impl IndexOperation {