@@ -13,11 +13,11 @@ the `perm` and `temp` buckets are identical in structure. The only difference is
13
13
that the `temp` bucket is cleared on restart of the db.
14
14
15
15
rules -> perm -> rule-name -> global -> {k:v}
16
- -> sessions -> sessionID -> session-kv-store -> {k:v}
16
+ -> sessions -> group ID -> session-kv-store -> {k:v}
17
17
-> feature-kv-stores -> feature-name -> {k:v}
18
18
19
19
-> temp -> rule-name -> global -> {k:v}
20
- -> sessions -> sessionID -> session-kv-store -> {k:v}
20
+ -> sessions -> group ID -> session-kv-store -> {k:v}
21
21
-> feature-kv-stores -> feature-name -> {k:v}
22
22
*/
23
23
44
44
sessKVStoreBucketKey = []byte ("session-kv-store" )
45
45
46
46
// featureKVStoreBucketKey is the kye under which a kv store specific
47
- // the session id and feature name is stored.
47
+ // the group id and feature name is stored.
48
48
featureKVStoreBucketKey = []byte ("feature-kv-store" )
49
49
)
50
50
@@ -72,12 +72,12 @@ type KVStores interface {
72
72
type KVStoreTx interface {
73
73
// Global returns a persisted global, rule-name indexed, kv store. A
74
74
// rule with a given name will have access to this store independent of
75
- // session ID or feature.
75
+ // group ID or feature.
76
76
Global () KVStore
77
77
78
78
// Local returns a persisted local kv store for the rule. Depending on
79
79
// how the implementation is initialised, this will either be under the
80
- // session ID namespace or the session ID _and_ feature name namespace.
80
+ // group ID namespace or the group ID _and_ feature name namespace.
81
81
Local () KVStore
82
82
83
83
// GlobalTemp is similar to the Global store except that its contents
@@ -105,17 +105,17 @@ type KVStore interface {
105
105
106
106
// RulesDB can be used to initialise a new rules.KVStores.
107
107
type RulesDB interface {
108
- GetKVStores (rule string , sessionID session.ID , feature string ) KVStores
108
+ GetKVStores (rule string , groupID session.ID , feature string ) KVStores
109
109
}
110
110
111
111
// GetKVStores constructs a new rules.KVStores backed by a bbolt db.
112
- func (db * DB ) GetKVStores (rule string , sessionID session.ID ,
112
+ func (db * DB ) GetKVStores (rule string , groupID session.ID ,
113
113
feature string ) KVStores {
114
114
115
115
return & kvStores {
116
116
DB : db ,
117
117
ruleName : rule ,
118
- sessionID : sessionID ,
118
+ groupID : groupID ,
119
119
featureName : feature ,
120
120
}
121
121
}
@@ -124,7 +124,7 @@ func (db *DB) GetKVStores(rule string, sessionID session.ID,
124
124
type kvStores struct {
125
125
* DB
126
126
ruleName string
127
- sessionID session.ID
127
+ groupID session.ID
128
128
featureName string
129
129
}
130
130
@@ -237,10 +237,10 @@ func (tx *kvStoreTx) Global() KVStore {
237
237
//
238
238
// NOTE: this is part of the KVStoreTx interface.
239
239
func (tx * kvStoreTx ) Local () KVStore {
240
- fn := getSessionRuleBucket (true , tx .ruleName , tx .sessionID )
240
+ fn := getSessionRuleBucket (true , tx .ruleName , tx .groupID )
241
241
if tx .featureName != "" {
242
242
fn = getSessionFeatureRuleBucket (
243
- true , tx .ruleName , tx .sessionID , tx .featureName ,
243
+ true , tx .ruleName , tx .groupID , tx .featureName ,
244
244
)
245
245
}
246
246
@@ -268,10 +268,10 @@ func (tx *kvStoreTx) GlobalTemp() KVStore {
268
268
//
269
269
// NOTE: this is part of the KVStoreTx interface.
270
270
func (tx * kvStoreTx ) LocalTemp () KVStore {
271
- fn := getSessionRuleBucket (true , tx .ruleName , tx .sessionID )
271
+ fn := getSessionRuleBucket (true , tx .ruleName , tx .groupID )
272
272
if tx .featureName != "" {
273
273
fn = getSessionFeatureRuleBucket (
274
- false , tx .ruleName , tx .sessionID , tx .featureName ,
274
+ false , tx .ruleName , tx .groupID , tx .featureName ,
275
275
)
276
276
}
277
277
@@ -390,11 +390,11 @@ func getGlobalRuleBucket(perm bool, ruleName string) getBucketFunc {
390
390
}
391
391
392
392
// getSessionRuleBucket returns a function that can be used to fetch the
393
- // bucket under which a kv store for a specific rule-name and session ID is
393
+ // bucket under which a kv store for a specific rule-name and group ID is
394
394
// stored. The `perm` param determines if the temporary or permanent store is
395
395
// used.
396
396
func getSessionRuleBucket (perm bool , ruleName string ,
397
- sessionID session.ID ) getBucketFunc {
397
+ groupID session.ID ) getBucketFunc {
398
398
399
399
return func (tx * bbolt.Tx , create bool ) (* bbolt.Bucket , error ) {
400
400
ruleBucket , err := getRuleBucket (perm , ruleName )(tx , create )
@@ -414,27 +414,28 @@ func getSessionRuleBucket(perm bool, ruleName string,
414
414
return nil , err
415
415
}
416
416
417
- return sessBucket .CreateBucketIfNotExists (sessionID [:])
417
+ return sessBucket .CreateBucketIfNotExists (groupID [:])
418
418
}
419
419
420
420
sessBucket := ruleBucket .Bucket (sessKVStoreBucketKey )
421
421
if sessBucket == nil {
422
422
return nil , nil
423
423
}
424
- return sessBucket .Bucket (sessionID [:]), nil
424
+ return sessBucket .Bucket (groupID [:]), nil
425
425
}
426
426
}
427
427
428
428
// getSessionFeatureRuleBucket returns a function that can be used to fetch the
429
- // bucket under which a kv store for a specific rule-name, session ID and
429
+ // bucket under which a kv store for a specific rule-name, group ID and
430
430
// feature name is stored. The `perm` param determines if the temporary or
431
431
// permanent store is used.
432
432
func getSessionFeatureRuleBucket (perm bool , ruleName string ,
433
- sessionID session.ID , featureName string ) getBucketFunc {
433
+ groupID session.ID , featureName string ) getBucketFunc {
434
434
435
435
return func (tx * bbolt.Tx , create bool ) (* bbolt.Bucket , error ) {
436
436
sessBucket , err := getSessionRuleBucket (
437
- perm , ruleName , sessionID )(tx , create )
437
+ perm , ruleName , groupID ,
438
+ )(tx , create )
438
439
if err != nil {
439
440
return nil , err
440
441
}
0 commit comments