From 2d35e4cfda6963f523aff0effa4f724bac4a369d Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 13 May 2024 17:10:26 -0400 Subject: [PATCH] mgr/smb: add a new protocol for a FindingConfigStore Add a new FindingConfigStore protocol. This FindingConfigStore is a ConfigStore that provides a method for more quickly/efficiently finding specific entries in the store. This is opposed to walking all keys and getting all objects and comparing them. This protocol is optional and will only be implemented by a few specialized stores. Signed-off-by: John Mulligan --- src/pybind/mgr/smb/proto.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pybind/mgr/smb/proto.py b/src/pybind/mgr/smb/proto.py index ffcc647a48e..23fa8f5c209 100644 --- a/src/pybind/mgr/smb/proto.py +++ b/src/pybind/mgr/smb/proto.py @@ -48,6 +48,7 @@ class Simplifiable(Protocol): EntryKey = Tuple[str, str] +FindParams = Dict[str, Any] class ConfigEntry(Protocol): @@ -102,6 +103,21 @@ class ConfigStore(ConfigStoreListing, Protocol): ... # pragma: no cover +class FindingConfigStore(ConfigStore, Protocol): + """A protocol for a config store that can more efficiently find + items within the the store. + """ + + def find_entries( + self, ns: str, params: FindParams + ) -> Collection[ConfigEntry]: + """Find entries in the store matching the given params. + Params is a dict that will be compared to the same keys/attributes of + the objects being searched. Only exact matches will be returned. + """ + ... # pragma: no cover + + class PathResolver(Protocol): """A protocol describing a type that can map volumes, subvolumes, and paths to real paths within a cephfs system. -- 2.47.3