Skip to content

Commit 40819b0

Browse files
persistency_kvs: add architecture UML descriptions
Signed-off-by: Sven Bachmann <sven.bachmann.ext@qorix.ai>
1 parent 29dd08f commit 40819b0

10 files changed

+283
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@startuml
2+
3+
title Sequence Diagram: KVS Builder
4+
5+
participant "User" as actor
6+
participant "«component» :builder" as builder
7+
participant "«component» :kvs" as kvs
8+
9+
actor -> builder: Create KVS builder
10+
builder --> actor: KVS builder instance
11+
12+
actor -> builder: Set need_defaults flag
13+
builder --> actor: KVS builder instance
14+
15+
actor -> builder: Set need_kvs flag
16+
builder --> actor: KVS builder instance
17+
18+
actor -> builder: Build KVS instance
19+
builder -> kvs: Open KVS with builder config
20+
21+
alt kvs-open
22+
kvs --> builder: KVS instance
23+
builder --> actor: KVS instance
24+
else kvs-open-error
25+
kvs --> builder: KVS ErrorCode
26+
builder --> actor: KVS ErrorCode
27+
end
28+
29+
@enduml
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@startuml
2+
3+
title Sequence Diagram: Check if Key contains Default Value
4+
5+
participant "User" as actor
6+
participant "«component» :kvs" as kvs
7+
8+
actor -> kvs: Does key has default value
9+
10+
alt default-key-exists
11+
alt key-exists
12+
alt default-and-key-match
13+
kvs --> actor: Key contains default value
14+
else key-doesnt-exist
15+
kvs --> actor: Key doesn't containt default value
16+
end
17+
else key-doesnt-exist
18+
kvs --> actor: Key contains default value
19+
end
20+
else default-doesnt-exist
21+
kvs --> actor: Key doesn't contain default value
22+
end
23+
24+
@enduml
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@startuml
2+
3+
title Sequence Diagram: Delete Key from KVS Instance
4+
5+
participant "User" as actor
6+
participant "«component» :kvs" as kvs
7+
8+
actor -> kvs: Remove key
9+
10+
alt key-exists
11+
kvs --> actor: Successfully deleted key
12+
else key-doesnt-exist
13+
kvs --> actor: Key-Not-Found-Error
14+
end
15+
16+
@enduml
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
@startuml
2+
3+
title Sequence Diagram: Flush Local Representation to Data File
4+
5+
participant "User" as actor
6+
participant "«component» :kvs" as kvs
7+
participant "«component» :snapshot" as snapshot
8+
participant "«component» :TinyJSON" as json_parser
9+
participant "«component» :fs" as fs
10+
participant "«component» :Adler32" as hasher
11+
12+
actor -> kvs: Flush KVS
13+
14+
kvs -> json_parser: Generate string from local representation
15+
16+
alt json-string
17+
json_parser --> kvs: JSON data string
18+
else json-string-error
19+
json_parser --> kvs: JSON generator error
20+
kvs --> actor: JSON generator error
21+
end
22+
23+
kvs -> snapshot: Rotate snapshots
24+
25+
alt snapshot-rotate
26+
snapshot -> kvs: Snapshots rotated
27+
else snapshot-rotate-error
28+
snapshot --> kvs: Snapshot-Rotate-Error
29+
kvs --> actor: Snapshot-Rotate-Error
30+
end
31+
32+
kvs -> hasher: Create JSON data string hash
33+
34+
alt hash-created
35+
hasher --> kvs: Data hash
36+
else hash-create-error
37+
hasher --> kvs: Hash-Calc-Error
38+
kvs --> actor: Hash-Calc-Error
39+
end
40+
41+
kvs -> fs: Write JSON data string to file
42+
43+
alt file-write
44+
fs --> kvs: File successfully written
45+
else file-write-error
46+
fs --> kvs: File-Write-Error
47+
kvs --> actor: File-Write-Error
48+
end
49+
50+
kvs -> fs: Write JSON data hash to file
51+
52+
alt file-hash-write
53+
fs --> kvs: Hash file successfully written
54+
kvs --> actor: Flush successful
55+
else file-hash-write-error
56+
fs --> kvs: File-Hash-Write-Error
57+
kvs --> actor: File-Hash-Write-Error
58+
end
59+
60+
@enduml
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@startuml
2+
3+
title Sequence Diagram: Read Key from KVS Instance
4+
5+
participant "User" as actor
6+
participant "«component» :kvs" as kvs
7+
8+
actor -> kvs: Get value for key
9+
10+
alt key-exists
11+
kvs --> actor: Return value for key
12+
else key-doesnt-exist
13+
alt default-exists
14+
kvs --> actor: Return default value for key
15+
else default-doesnt-exist
16+
kvs --> actor: Key-Not-Found error
17+
end
18+
end
19+
20+
@enduml
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@startuml
2+
3+
title Sequence Diagram: Read Data into Local Representation (KvsValue)
4+
5+
participant "Builder" as actor
6+
participant "«component» :kvs" as kvs
7+
participant "«component» :TinyJSON" as json_parser
8+
participant "«component» :fs" as fs
9+
participant "«component» :Adler32" as hasher
10+
11+
actor -> kvs: Open KVS
12+
13+
kvs -> fs: Read defaults file
14+
15+
alt file-exists
16+
fs --> kvs: Defaults file content (JSON)
17+
else file-based-error
18+
fs --> kvs: File-Error
19+
kvs -> actor: File-Error
20+
end
21+
22+
kvs -> fs: Read defaults file hash
23+
24+
alt file-exists
25+
fs --> kvs: Defaults file hash
26+
else file-based-error
27+
fs --> kvs: File-Error
28+
kvs -> actor: File-Error
29+
end
30+
31+
kvs -> hasher: Generate defaults file hash
32+
hasher --> kvs: Defaults file generated hash
33+
34+
alt hash-matches
35+
kvs -> json_parser: Parse JSON data
36+
else hash-match-error
37+
kvs -> actor: Hash-Error
38+
end
39+
40+
alt parsing-success
41+
json_parser --> kvs: Parsed JSON object
42+
else parsing-based-error
43+
json_parser -> kvs: Parser-Error
44+
kvs -> actor: Parser-Error
45+
end
46+
47+
kvs --> actor: KVS instance
48+
49+
@enduml
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@startuml
2+
3+
title Sequence Diagram: Restore Snapshot
4+
5+
participant "User" as actor
6+
participant "«component» :kvs" as kvs
7+
participant "«component» :snapshot" as snapshot
8+
9+
actor -> kvs: Restore snapshot
10+
11+
alt snapshot-found
12+
snapshot --> kvs: Snapshot restored into local representation
13+
kvs --> actor: Snapshot restored successfully
14+
else snapshot-error
15+
snapshot --> kvs: Snapshot-Not-Available-Error
16+
kvs --> actor: Snapshot-Not-Available-Error
17+
end
18+
19+
@enduml
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@startuml
2+
3+
title Sequence Diagram: Write Key to KVS Instance
4+
5+
participant "User" as actor
6+
participant "«component» :kvs" as kvs
7+
8+
actor -> kvs: Set value for key
9+
kvs --> actor: Value set for key
10+
11+
@enduml
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@startuml
2+
3+
interface Kvs {
4+
open
5+
flush_on_exit
6+
reset
7+
get_all_keys
8+
key_exists
9+
get_value
10+
get_default_value
11+
has_default_value
12+
set_default_value
13+
set_value
14+
remove_key
15+
flush
16+
snapshot_count
17+
snapshot_max_count
18+
snapshot_restore
19+
get_kvs_filename
20+
get_hash_filename
21+
}
22+
23+
@enduml
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@startuml
2+
allowmixing
3+
4+
title Static View - key_val_storage
5+
6+
!include kvs_interface.puml
7+
8+
9+
skinparam package {
10+
BackgroundColor #E0E0D0
11+
BorderColor Black
12+
backgroundColor<<feature>> yellow
13+
}
14+
15+
skinparam component {
16+
backgroundColor<<component>> white
17+
}
18+
19+
' Define Features
20+
package "key_val_storage" <<feature>> {
21+
component kvs <<component>>
22+
component fs <<component>>
23+
component tiny_json <<component>>
24+
}
25+
26+
kvs -u- Kvs
27+
28+
kvs ..> tiny_json : use
29+
kvs ..> fs : use
30+
31+
32+
@enduml

0 commit comments

Comments
 (0)