]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/smb: add a new protocol for a FindingConfigStore
authorJohn Mulligan <jmulligan@redhat.com>
Mon, 13 May 2024 21:10:26 +0000 (17:10 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Sat, 6 Jul 2024 14:00:18 +0000 (10:00 -0400)
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 <jmulligan@redhat.com>
src/pybind/mgr/smb/proto.py

index ffcc647a48edadabf44e2a6472c7dcfdb0fe6499..23fa8f5c209ac82f6c55e4b8925c729debda6b89 100644 (file)
@@ -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.