Skip to content

Commit 6d9e126

Browse files
mgr/smb: add a RawConfigEntry protocol type
Previously, the ConfigEntry type was created to be general interface for serializing structures to JSON and persist them in a store. However, there are times we want to retain data in a store that is not serialized JSON - but just raw data. Create a new protocol for that purpose. Signed-off-by: John Mulligan <[email protected]>
1 parent 2698e05 commit 6d9e126

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

src/pybind/mgr/smb/proto.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,27 @@ def __str__(self) -> str:
6262
... # pragma: no cover
6363

6464

65-
class ConfigEntry(Protocol):
65+
class BaseEntry(Protocol):
66+
"""Base protocol class for Entry objects. Entry objects are stored
67+
peristently and can by identified by an internal key or URI.
68+
"""
69+
70+
def remove(self) -> bool:
71+
... # pragma: no cover
72+
73+
def exists(self) -> bool:
74+
... # pragma: no cover
75+
76+
@property
77+
def uri(self) -> str:
78+
... # pragma: no cover
79+
80+
@property
81+
def full_key(self) -> EntryKey:
82+
... # pragma: no cover
83+
84+
85+
class ConfigEntry(BaseEntry, Protocol):
6686
"""A protocol for describing a configuration object that can be kept within
6787
a configuration store. Has the ability to identify itself either by a
6888
relative key or by a global URI value.
@@ -74,18 +94,14 @@ def get(self) -> Simplified:
7494
def set(self, obj: Simplified) -> None:
7595
... # pragma: no cover
7696

77-
def remove(self) -> bool:
78-
... # pragma: no cover
7997

80-
def exists(self) -> bool:
81-
... # pragma: no cover
98+
class RawConfigEntry(BaseEntry, Protocol):
99+
"""Like a ConfigEntry but for opaque data blobs."""
82100

83-
@property
84-
def uri(self) -> str:
101+
def get_data(self) -> str:
85102
... # pragma: no cover
86103

87-
@property
88-
def full_key(self) -> EntryKey:
104+
def set_data(self, obj: Simplified) -> None:
89105
... # pragma: no cover
90106

91107

0 commit comments

Comments
 (0)