]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/smb: add TransactingConfigStore protocol
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 29 May 2024 23:27:57 +0000 (19:27 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Sat, 6 Jul 2024 18:53:06 +0000 (14:53 -0400)
Add a new TransactingConfigStore protocol. This TransactingConfigStore is a
ConfigStore that provides a method for establishing a transaction.
What a transaction means can depend on the store but generally it is
intended to provide a way to use database transactions with the store
abstraction.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/smb/proto.py

index 23fa8f5c209ac82f6c55e4b8925c729debda6b89..858975f7390dbdcd25bae3400a40679c0fe158ea 100644 (file)
@@ -4,6 +4,7 @@ from typing import (
     TYPE_CHECKING,
     Any,
     Collection,
+    ContextManager,
     Dict,
     Iterator,
     List,
@@ -118,6 +119,20 @@ class FindingConfigStore(ConfigStore, Protocol):
         ...  # pragma: no cover
 
 
+class TransactingConfigStore(ConfigStore, Protocol):
+    """A protocol for a config store that supports transactions.
+    Using the transactions can make using the store more robust or
+    efficient.
+    """
+
+    def transaction(self) -> ContextManager[None]:
+        """Return a context manager that wraps a transaction. What exactly
+        this means depends on the store. Typically this would wrap a database
+        transaction.
+        """
+        ...  # 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.