44 lines
844 B
Go
44 lines
844 B
Go
|
package http
|
||
|
|
||
|
import (
|
||
|
"git.defalsify.org/vise.git/db"
|
||
|
"git.defalsify.org/vise.git/persist"
|
||
|
)
|
||
|
|
||
|
type Storage struct {
|
||
|
Persister *persist.Persister
|
||
|
UserdataDb db.Db
|
||
|
}
|
||
|
|
||
|
type StorageProvider interface {
|
||
|
Get(sessionId string) (Storage, error)
|
||
|
Put(sessionId string, storage Storage) error
|
||
|
Close() error
|
||
|
}
|
||
|
|
||
|
type SimpleStorageProvider struct {
|
||
|
Storage
|
||
|
}
|
||
|
|
||
|
func NewSimpleStorageProvider(stateStore db.Db, userdataStore db.Db) StorageProvider {
|
||
|
pe := persist.NewPersister(stateStore)
|
||
|
return &SimpleStorageProvider{
|
||
|
Storage: Storage{
|
||
|
Persister: pe,
|
||
|
UserdataDb: userdataStore,
|
||
|
},
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (*SimpleStorageProvider) Get(sessionId string) (Storage, error) {
|
||
|
return Storage{}, nil
|
||
|
}
|
||
|
|
||
|
func (*SimpleStorageProvider) Put(sessionId string, storage Storage) error {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (*SimpleStorageProvider) Close() error {
|
||
|
return nil
|
||
|
}
|