Expose methods required for the stream sync service #147
| @ -1,17 +1,15 @@ | |||||||
| package utils | package common | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
| 
 | 
 | ||||||
| 	"git.grassecon.net/urdt/ussd/common" |  | ||||||
| 
 |  | ||||||
| 	"git.defalsify.org/vise.git/db" | 	"git.defalsify.org/vise.git/db" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| type DataStore interface { | type DataStore interface { | ||||||
| 	db.Db | 	db.Db | ||||||
| 	ReadEntry(ctx context.Context, sessionId string, typ common.DataTyp) ([]byte, error) | 	ReadEntry(ctx context.Context, sessionId string, typ DataTyp) ([]byte, error) | ||||||
| 	WriteEntry(ctx context.Context, sessionId string, typ common.DataTyp, value []byte) error | 	WriteEntry(ctx context.Context, sessionId string, typ DataTyp, value []byte) error | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type UserDataStore struct { | type UserDataStore struct { | ||||||
| @ -19,16 +17,16 @@ type UserDataStore struct { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // ReadEntry retrieves an entry from the store based on the provided parameters.
 | // ReadEntry retrieves an entry from the store based on the provided parameters.
 | ||||||
| func (store *UserDataStore) ReadEntry(ctx context.Context, sessionId string, typ common.DataTyp) ([]byte, error) { | func (store *UserDataStore) ReadEntry(ctx context.Context, sessionId string, typ DataTyp) ([]byte, error) { | ||||||
| 	store.SetPrefix(db.DATATYPE_USERDATA) | 	store.SetPrefix(db.DATATYPE_USERDATA) | ||||||
| 	store.SetSession(sessionId) | 	store.SetSession(sessionId) | ||||||
| 	k := common.PackKey(typ, []byte(sessionId)) | 	k := PackKey(typ, []byte(sessionId)) | ||||||
| 	return store.Get(ctx, k) | 	return store.Get(ctx, k) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (store *UserDataStore) WriteEntry(ctx context.Context, sessionId string, typ common.DataTyp, value []byte) error { | func (store *UserDataStore) WriteEntry(ctx context.Context, sessionId string, typ DataTyp, value []byte) error { | ||||||
| 	store.SetPrefix(db.DATATYPE_USERDATA) | 	store.SetPrefix(db.DATATYPE_USERDATA) | ||||||
| 	store.SetSession(sessionId) | 	store.SetSession(sessionId) | ||||||
| 	k := common.PackKey(typ, []byte(sessionId)) | 	k := PackKey(typ, []byte(sessionId)) | ||||||
| 	return store.Put(ctx, k, value) | 	return store.Put(ctx, k, value) | ||||||
| } | } | ||||||
| @ -63,7 +63,7 @@ type Handlers struct { | |||||||
| 	pe             *persist.Persister | 	pe             *persist.Persister | ||||||
| 	st             *state.State | 	st             *state.State | ||||||
| 	ca             cache.Memory | 	ca             cache.Memory | ||||||
| 	userdataStore  utils.DataStore | 	userdataStore  common.DataStore | ||||||
| 	flagManager    *asm.FlagParser | 	flagManager    *asm.FlagParser | ||||||
| 	accountService server.AccountServiceInterface | 	accountService server.AccountServiceInterface | ||||||
| } | } | ||||||
| @ -72,7 +72,7 @@ func NewHandlers(appFlags *asm.FlagParser, userdataStore db.Db, accountService s | |||||||
| 	if userdataStore == nil { | 	if userdataStore == nil { | ||||||
| 		return nil, fmt.Errorf("cannot create handler with nil userdata store") | 		return nil, fmt.Errorf("cannot create handler with nil userdata store") | ||||||
| 	} | 	} | ||||||
| 	userDb := &utils.UserDataStore{ | 	userDb := &common.UserDataStore{ | ||||||
| 		Db: userdataStore, | 		Db: userdataStore, | ||||||
| 	} | 	} | ||||||
| 	h := &Handlers{ | 	h := &Handlers{ | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user