make packKey accessible from tests
This commit is contained in:
parent
dd97531861
commit
01c13ec581
@ -33,15 +33,16 @@ func typToBytes(typ DataTyp) []byte {
|
|||||||
return b[:]
|
return b[:]
|
||||||
}
|
}
|
||||||
|
|
||||||
func packKey(typ DataTyp, data []byte) []byte {
|
func PackKey(typ DataTyp, data []byte) []byte {
|
||||||
v := typToBytes(typ)
|
v := typToBytes(typ)
|
||||||
return append(v, data...)
|
return append(v, data...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadEntry(ctx context.Context, store db.Db, sessionId string, typ DataTyp) ([]byte, error) {
|
func ReadEntry(ctx context.Context, store db.Db, sessionId string, typ DataTyp) ([]byte, error) {
|
||||||
|
|
||||||
store.SetPrefix(db.DATATYPE_USERDATA)
|
store.SetPrefix(db.DATATYPE_USERDATA)
|
||||||
store.SetSession(sessionId)
|
store.SetSession(sessionId)
|
||||||
k := packKey(typ, []byte(sessionId))
|
k := PackKey(typ, []byte(sessionId))
|
||||||
b, err := store.Get(ctx, k)
|
b, err := store.Get(ctx, k)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -52,6 +53,6 @@ func ReadEntry(ctx context.Context, store db.Db, sessionId string, typ DataTyp)
|
|||||||
func WriteEntry(ctx context.Context, store db.Db, sessionId string, typ DataTyp, value []byte) error {
|
func WriteEntry(ctx context.Context, store db.Db, sessionId string, typ DataTyp, value []byte) error {
|
||||||
store.SetPrefix(db.DATATYPE_USERDATA)
|
store.SetPrefix(db.DATATYPE_USERDATA)
|
||||||
store.SetSession(sessionId)
|
store.SetSession(sessionId)
|
||||||
k := packKey(typ, []byte(sessionId))
|
k := PackKey(typ, []byte(sessionId))
|
||||||
return store.Put(ctx, k, value)
|
return store.Put(ctx, k, value)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user