1+ @startuml Persistency class diagram
2+
3+ package "kvs_builder" {
4+ ~ class KvsInner {
5+ ~ parameters : KvsParameters
6+ ~ data : KvsData
7+ }
8+
9+ +class KvsBuilder {
10+ {static } - KVS_POOL : list<KvsInner>
11+ - parameters : KvsParameters
12+
13+ +new (instance_id : InstanceId ): KvsBuilder
14+ {static } +max_instances (): usize
15+ +defaults (mode : KvsDefaults ): KvsBuilder
16+ +kvs_load (mode : KvsLoad ): KvsBuilder
17+ +backend_parameters (parameters : KvsMap ): KvsBuilder
18+ +build (): Kvs
19+ }
20+
21+ KvsInner <-- KvsBuilder
22+ }
23+
24+ package "kvs_api" {
25+ +interface KvsApi {
26+ +reset ()
27+ +reset_key (key : string )
28+ +get_all_keys (): list <string >
29+ +key_exists (key : string ): bool
30+ +get_value (key : string ): KvsValue
31+ +get_value_as <T >(key : string ): T
32+ +get_default_value (key : string ): KvsValue
33+ +is_value_default (key : string ): bool
34+ +set_value <T >(key : string , value : T )
35+ +remove_key (key : string )
36+ +flush ()
37+ +snapshot_count (): usize
38+ +snapshot_max_count (): usize
39+ +snapshot_restore (snapshot_id : SnapshotId )
40+ }
41+ }
42+
43+ package "kvs" {
44+ +class Kvs {
45+ - data : KvsData
46+ - parameters : KvsParameters
47+ - backend : KvsBackend
48+
49+ ~ new (data : KvsData, parameters: KvsParameters, backend: KvsBackend): Kvs
50+ +parameters (): KvsParameters
51+
52+ +reset ()
53+ +reset_key (key : string )
54+ +get_all_keys (): list <string >
55+ +key_exists (key : string ): bool
56+ +get_value (key : string ): KvsValue
57+ +get_value_as <T >(key : string ): T
58+ +get_default_value (key : string ): KvsValue
59+ +is_value_default (key : string ): bool
60+ +set_value <T >(key : string , value : T )
61+ +remove_key (key : string )
62+ +flush ()
63+ +snapshot_count (): usize
64+ +snapshot_max_count (): usize
65+ +snapshot_restore (snapshot_id : SnapshotId )
66+ }
67+ }
68+
69+ KvsApi <|.. Kvs
70+ KvsBuilder -- Kvs
71+
72+ package "kvs_backend_registry" {
73+ +class KvsBackendRegistry {
74+ {static } - REGISTERED_BACKENDS : map<string, KvsBackendFactory>
75+
76+ {static } ~ from_name (name : string) -> Result<&Box<dyn KvsBackendFactory>, ErrorCode>
77+ {static } ~ from_parameters (parameters : KvsMap) -> Result<&Box<dyn KvsBackendFactory>, ErrorCode>
78+
79+ {static } +register (backend_factory : KvsBackendFactory )
80+ }
81+ }
82+
83+ KvsBackendRegistry .. KvsBuilder
84+
85+ package "kvs_backend" {
86+ +interface KvsBackend {
87+ +load_kvs (instance_id : InstanceId , snapshot_id : SnapshotId ): KvsMap
88+ +load_defaults (instance_id : InstanceId ): KvsMap
89+ +flush (instance_id : InstanceId , kvs_map : KvsMap )
90+ +snapshot_count (instance_id : InstanceId ): usize
91+ +snapshot_max_count (): usize
92+ +snapshot_restore (instance_id : InstanceId , snapshot_id : SnapshotId ): KvsMap
93+ }
94+
95+ +interface KvsBackendFactory {
96+ +create (parameters : KvsMap ): KvsBackend
97+ }
98+ }
99+
100+ package "json_backend" {
101+ ~ class JsonBackend {
102+ +load_kvs (instance_id : InstanceId , snapshot_id : SnapshotId ): KvsMap
103+ +load_defaults (instance_id : InstanceId ): KvsMap
104+ +flush (instance_id : InstanceId , kvs_map : KvsMap )
105+ +snapshot_count (instance_id : InstanceId ): usize
106+ +snapshot_max_count (): usize
107+ +snapshot_restore (instance_id : InstanceId , snapshot_id : SnapshotId ): KvsMap
108+ }
109+
110+ ~ class JsonBackendFactory {
111+ +create (parameters : KvsMap ): KvsBackend
112+ }
113+ }
114+
115+ KvsBackend <-- Kvs
116+
117+ KvsBackendRegistry --> KvsBackendFactory
118+ KvsBackendFactory -- KvsBackend
119+
120+ KvsBackend <|.. JsonBackend
121+ KvsBackendFactory <|.. JsonBackendFactory
122+ JsonBackendFactory -- JsonBackend
123+
124+ @enduml
0 commit comments