From: John Mulligan Date: Wed, 29 May 2024 23:27:57 +0000 (-0400) Subject: mgr/smb: add TransactingConfigStore protocol X-Git-Tag: testing/wip-vshankar-testing-20240718.183435-debug~4^2~12 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=29ab71466be6651c40e5e8b421f4b096ef395d7a;p=ceph-ci.git mgr/smb: add TransactingConfigStore protocol 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 --- diff --git a/src/pybind/mgr/smb/proto.py b/src/pybind/mgr/smb/proto.py index 23fa8f5c209..858975f7390 100644 --- a/src/pybind/mgr/smb/proto.py +++ b/src/pybind/mgr/smb/proto.py @@ -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.