From 29ab71466be6651c40e5e8b421f4b096ef395d7a Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 29 May 2024 19:27:57 -0400 Subject: [PATCH] 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 --- src/pybind/mgr/smb/proto.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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. -- 2.39.5