Skip to content

Commit 0259fc8

Browse files
committed
firewalldb: add comment about reasoning behind persistent temp KV stores
1 parent 6f33893 commit 0259fc8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

firewalldb/kvstores.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ import (
99

1010
/*
1111
The KVStores are stored in the following structure in the KV db. Note that
12-
the `perm` and `temp` buckets are identical in structure. The only difference is
13-
that the `temp` bucket is cleared on restart of the db.
12+
the `perm` and `temp` buckets are identical in structure. The only difference
13+
is that the `temp` bucket is cleared on restart of the db. The reason persisting
14+
the temporary store changes instead of just keeping an in-memory store is that
15+
we can then guarantee idempotency if changes are made to both the permanent and
16+
temporary stores.
1417
1518
rules -> perm -> rule-name -> global -> {k:v}
1619
-> sessions -> group ID -> session-kv-store -> {k:v}
@@ -81,11 +84,17 @@ type KVStoreTx interface {
8184
Local() KVStore
8285

8386
// GlobalTemp is similar to the Global store except that its contents
84-
// is cleared upon restart of the database.
87+
// is cleared upon restart of the database. The reason persisting the
88+
// temporary store changes instead of just keeping an in-memory store is
89+
// that we can then guarantee idempotency if changes are made to both
90+
// the permanent and temporary stores.
8591
GlobalTemp() KVStore
8692

8793
// LocalTemp is similar to the Local store except that its contents is
88-
// cleared upon restart of the database.
94+
// cleared upon restart of the database. The reason persisting the
95+
// temporary store changes instead of just keeping an in-memory store is
96+
// that we can then guarantee idempotency if changes are made to both
97+
// the permanent and temporary stores.
8998
LocalTemp() KVStore
9099
}
91100

0 commit comments

Comments
 (0)