1+ @startuml ScorePersistencyKvsDesign
2+
3+ ' Define color schemes matching original design
4+ skinparam class {
5+ BackgroundColor <<interface>> LightYellow
6+ BorderColor <<interface>> DarkGoldenRod
7+ BackgroundColor <<implementation>> LightBlue
8+ BorderColor <<implementation>> DodgerBlue
9+ BackgroundColor <<mock>> LightPink
10+ BorderColor <<mock>> IndianRed
11+ }
12+
13+ class KvsBuilder <<implementation>> {
14+ - instance_id : InstanceId
15+ - need_defaults : KvsDefaults
16+ - need_kvs : KvsLoad
17+ - backend : IStorageBackend
18+ - {static} OpenedKvs : std::unordered_map<instanceId, std::shared_ptr<kvs> >
19+ __
20+ + KvsBuilder(const InstanceId& instance_id)
21+ + NeedDefaultsFlag(bool flag) : KvsBuilder&
22+ + NeedKvsFlag(bool flag) : KvsBuilder&
23+ + Backend(IStorageBackend backend) : KvsBuilder&
24+ + Build() : std::shared_ptr<Kvs>
25+ }
26+
27+
28+
29+ interface IStorageBackend <<interface >> {
30+ + LoadKvs (instance_id :InstanceId , snapshot_id :SnapshotId ):IKvs
31+ + LoadDefault (instance_id :InstanceId ):IKvs
32+ + Flush (instance_id :InstanceId , kvs :unordered_map <string ,kvs >
33+ + SnapshotCount (instance_id :InstanceId ):Result <size_t >
34+ + SnapshotRestore (instance_id :InstanceId , snapshot_id :SnapshotId ) : Kvs
35+ + SnapshotMaxCount () : Result <size_t >
36+ + SetSnapshotMaxCount (count :size_t ) : ResultBlank
37+ }
38+
39+ interface IKvs <<interface >> {
40+ + Reset ()
41+ + ResetKey (string key ):Result <bool >
42+ + GetAllKeys () : Result <vector <string >>
43+ + KeyExists (key :string ): Result <bool >
44+ + GetValue (key :string ) : Result <KvsValue >
45+ + GetDefaultValue (Key :string ) : Result <KvsValue >
46+ + HasDefaultValue (Key :string ) : Result <KvsValue >
47+ + SetValue (Key :string , value :KvsValue ): ResultBlank
48+ + RemoveKey (Key :string ) : ResultBlank
49+ + Flush () : ResultBlank
50+ + SnapshotCount : Result <size_t >
51+ + SnapshotMaxCount () : Result <size_t >
52+ + SnapshotRestore (snapshot_id :SnapshotId ): ResultBlank
53+ + GetHashFilename (snapshot_id :SnapshotId ): Result <filesystem ::path >
54+ }
55+
56+
57+ IStorageBackend - [hidden ]right - IKvs
58+ IStorageBackend_Mock - [hidden ]right - JsonBackend
59+ JsonBackend - [hidden ]right - IKvs_mock
60+ IKvs_mock - [hidden ]right - Kvs
61+
62+
63+ class IStorageBackend_Mock <<mock>> {
64+ + LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs
65+ + LoadDefault(instance_id:InstanceId):IKvs
66+ + Flush(instance_id:InstanceId, kvs:unordered_map<string,kvs>
67+ + SnapshotCount(instance_id:InstanceId):Result<size_t>
68+ + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs
69+ + SnapshotMaxCount() : Result<size_t>
70+ + SetSnapshotMaxCount(count:size_t) : ResultBlank
71+ }
72+
73+ class JsonBackend <<implementation>> {
74+ - Instance_id : InstanceId
75+ - filename_prefix : score::filesystem::path
76+ - filesystem : score::filesystem
77+ - parser : unique_ptr<IjsonParser> parser
78+ - writer : unique_ptr<IjsonWriter> writer
79+ - Directory : string
80+ __
81+ + JsonBackend(instance_id:InstanceId, filename_prefix:score::filesystem::path, filesystem:score::filesystem, Directory:string)
82+ + LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs
83+ + LoadDefault(instance_id:InstanceId):IKvs
84+ + Flush(instance_id:InstanceId, kvs:unordered_map<string,kvs>
85+ + SnapshotCount(instance_id:InstanceId):Result<size_t>
86+ + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs
87+ + GetHashFilename(snapshot_id:SnapshotId): Result<filesystem::path>
88+ + Dir(std::string&& dir_path) : Void
89+ + SnapshotMaxCount() : Result<size_t>
90+ + SetSnapshotMaxCount(count:size_t) : ResultBlank
91+
92+ }
93+
94+ class IKvs_mock <<mock>> {
95+ + Reset ()
96+ + ResetKey(string key):Result<bool>
97+ + GetAllKeys() : Result<vector<string>>
98+ + KeyExists(key:string): Result<bool>
99+ + GetValue(key:string) : Result<KvsValue>
100+ + GetDefaultValue(Key:string) : Result<KvsValue>
101+ + HasDefaultValue(Key:string) : Result<KvsValue>
102+ + SetValue(Key:string, value:KvsValue): ResultBlank
103+ + RemoveKey(Key:string) : ResultBlank
104+ + Flush () : ResultBlank
105+ + SnapshotCount: Result<size_t>
106+ + SnapshotMaxCount() : Result<size_t>
107+ + SnapshotRestore(snapshot_id:SnapshotId): ResultBlank
108+ + GetHashFilename(snapshot_id:SnapshotId): Result<filesystem::path>
109+ }
110+
111+ class Kvs <<implementation>> {
112+ + kvs : unordered_map<string, KvsValue>
113+ + default_kvs : unordered_map<string, KvsValue>
114+ + logger : unique_ptr<mw::log::logger> logger
115+ + Storage_backend : IStorageBackend
116+ __
117+ + Reset ()
118+ + ResetKey(string key):Result<bool>
119+ + GetAllKeys() : Result<vector<string>>
120+ + KeyExists(key:string): Result<bool>
121+ + GetValue(key:string) : Result<KvsValue>
122+ + GetDefaultValue(Key:string) : Result<KvsValue>
123+ + HasDefaultValue(Key:string) : Result<KvsValue>
124+ + SetValue(Key:string, value:KvsValue): ResultBlank
125+ + RemoveKey(Key:string) : ResultBlank
126+ + Flush () : ResultBlank
127+ + SnapshotCount: Result<size_t>
128+ + SnapshotMaxCount() : Result<size_t>
129+ + SnapshotRestore(snapshot_id:SnapshotId): ResultBlank
130+ + GetHashFilename(snapshot_id:SnapshotId): Result<filesystem::path>
131+ }
132+
133+ ' Relationships
134+ IStorageBackend_Mock -up -|> IStorageBackend : implements
135+ JsonBackend -up -|> IStorageBackend : implements
136+ IKvs_mock -up -|> IKvs : implements
137+ Kvs -up -|> IKvs : implements
138+
139+ ' Dependencies
140+ KvsBuilder ..> IStorageBackend : uses
141+ KvsBuilder ..> IKvs : uses
142+ IStorageBackend *-- IKvs : Composes
143+
144+
145+ @enduml
0 commit comments