Gofmt
This commit is contained in:
parent
f7d31e4e81
commit
d5e636fbd6
@ -9,23 +9,23 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logg = logging.NewVanilla().WithDomain("visedriver-config")
|
logg = logging.NewVanilla().WithDomain("visedriver-config")
|
||||||
defaultLanguage = "eng"
|
defaultLanguage = "eng"
|
||||||
languages []string
|
languages []string
|
||||||
DefaultLanguage string
|
DefaultLanguage string
|
||||||
dbConn string
|
dbConn string
|
||||||
dbConnMissing bool
|
dbConnMissing bool
|
||||||
stateDbConn string
|
stateDbConn string
|
||||||
resourceDbConn string
|
resourceDbConn string
|
||||||
userDbConn string
|
userDbConn string
|
||||||
Languages []string
|
Languages []string
|
||||||
)
|
)
|
||||||
|
|
||||||
func setLanguage() error {
|
func setLanguage() error {
|
||||||
defaultLanguage = env.GetEnv("DEFAULT_LANGUAGE", defaultLanguage)
|
defaultLanguage = env.GetEnv("DEFAULT_LANGUAGE", defaultLanguage)
|
||||||
languages = strings.Split(env.GetEnv("LANGUAGES", defaultLanguage), ",")
|
languages = strings.Split(env.GetEnv("LANGUAGES", defaultLanguage), ",")
|
||||||
haveDefaultLanguage := false
|
haveDefaultLanguage := false
|
||||||
for i, v := range(languages) {
|
for i, v := range languages {
|
||||||
languages[i] = strings.ReplaceAll(v, " ", "")
|
languages[i] = strings.ReplaceAll(v, " ", "")
|
||||||
if languages[i] == defaultLanguage {
|
if languages[i] == defaultLanguage {
|
||||||
haveDefaultLanguage = true
|
haveDefaultLanguage = true
|
||||||
@ -48,6 +48,7 @@ func setConn() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ApplyConn(connStr *string, stateConnStr *string, resourceConnStr *string, userConnStr *string) {
|
func ApplyConn(connStr *string, stateConnStr *string, resourceConnStr *string, userConnStr *string) {
|
||||||
|
logg.Infof("applyconn", "state", stateConnStr, "user", userConnStr)
|
||||||
if connStr != nil {
|
if connStr != nil {
|
||||||
dbConn = *connStr
|
dbConn = *connStr
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,9 @@ package entry
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"git.defalsify.org/vise.git/resource"
|
|
||||||
"git.defalsify.org/vise.git/persist"
|
"git.defalsify.org/vise.git/persist"
|
||||||
|
"git.defalsify.org/vise.git/resource"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EntryHandler interface {
|
type EntryHandler interface {
|
||||||
|
@ -7,20 +7,20 @@ import (
|
|||||||
"git.defalsify.org/vise.git/engine"
|
"git.defalsify.org/vise.git/engine"
|
||||||
"git.defalsify.org/vise.git/persist"
|
"git.defalsify.org/vise.git/persist"
|
||||||
"git.defalsify.org/vise.git/resource"
|
"git.defalsify.org/vise.git/resource"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/errors"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/entry"
|
"git.grassecon.net/grassrootseconomics/visedriver/entry"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/errors"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BaseRequestHandler struct {
|
type BaseRequestHandler struct {
|
||||||
cfgTemplate engine.Config
|
cfgTemplate engine.Config
|
||||||
rp RequestParser
|
rp RequestParser
|
||||||
rs resource.Resource
|
rs resource.Resource
|
||||||
hn entry.EntryHandler
|
hn entry.EntryHandler
|
||||||
provider storage.StorageProvider
|
provider storage.StorageProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
//func NewBaseRequestHandler(cfg engine.Config, rs resource.Resource, stateDb db.Db, userdataDb db.Db, rp request.RequestParser, hn *handlers.Handlers) *BaseRequestHandler {
|
// func NewBaseRequestHandler(cfg engine.Config, rs resource.Resource, stateDb db.Db, userdataDb db.Db, rp request.RequestParser, hn *handlers.Handlers) *BaseRequestHandler {
|
||||||
func NewBaseRequestHandler(cfg engine.Config, rs resource.Resource, stateDb db.Db, userdataDb db.Db, rp RequestParser, hn entry.EntryHandler) *BaseRequestHandler {
|
func NewBaseRequestHandler(cfg engine.Config, rs resource.Resource, stateDb db.Db, userdataDb db.Db, rp RequestParser, hn entry.EntryHandler) *BaseRequestHandler {
|
||||||
return &BaseRequestHandler{
|
return &BaseRequestHandler{
|
||||||
cfgTemplate: cfg,
|
cfgTemplate: cfg,
|
||||||
@ -44,7 +44,7 @@ func (f *BaseRequestHandler) GetEngine(cfg engine.Config, rs resource.Resource,
|
|||||||
return en
|
return en
|
||||||
}
|
}
|
||||||
|
|
||||||
func(f *BaseRequestHandler) Process(rqs RequestSession) (RequestSession, error) {
|
func (f *BaseRequestHandler) Process(rqs RequestSession) (RequestSession, error) {
|
||||||
var r bool
|
var r bool
|
||||||
var err error
|
var err error
|
||||||
var ok bool
|
var ok bool
|
||||||
@ -92,13 +92,13 @@ func(f *BaseRequestHandler) Process(rqs RequestSession) (RequestSession, error)
|
|||||||
return rqs, nil
|
return rqs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func(f *BaseRequestHandler) Output(rqs RequestSession) (RequestSession, error) {
|
func (f *BaseRequestHandler) Output(rqs RequestSession) (RequestSession, error) {
|
||||||
var err error
|
var err error
|
||||||
_, err = rqs.Engine.Flush(rqs.Ctx, rqs.Writer)
|
_, err = rqs.Engine.Flush(rqs.Ctx, rqs.Writer)
|
||||||
return rqs, err
|
return rqs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func(f *BaseRequestHandler) Reset(ctx context.Context, rqs RequestSession) (RequestSession, error) {
|
func (f *BaseRequestHandler) Reset(ctx context.Context, rqs RequestSession) (RequestSession, error) {
|
||||||
defer f.provider.Put(ctx, rqs.Config.SessionId, rqs.Storage)
|
defer f.provider.Put(ctx, rqs.Config.SessionId, rqs.Storage)
|
||||||
return rqs, rqs.Engine.Finish(ctx)
|
return rqs, rqs.Engine.Finish(ctx)
|
||||||
}
|
}
|
||||||
@ -107,6 +107,6 @@ func (f *BaseRequestHandler) GetConfig() engine.Config {
|
|||||||
return f.cfgTemplate
|
return f.cfgTemplate
|
||||||
}
|
}
|
||||||
|
|
||||||
func(f *BaseRequestHandler) GetRequestParser() RequestParser {
|
func (f *BaseRequestHandler) GetRequestParser() RequestParser {
|
||||||
return f.rp
|
return f.rp
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"git.defalsify.org/vise.git/logging"
|
"git.defalsify.org/vise.git/logging"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/errors"
|
"git.grassecon.net/grassrootseconomics/visedriver/errors"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -10,8 +10,8 @@ import (
|
|||||||
|
|
||||||
"git.defalsify.org/vise.git/engine"
|
"git.defalsify.org/vise.git/engine"
|
||||||
viseerrors "git.grassecon.net/grassrootseconomics/visedriver/errors"
|
viseerrors "git.grassecon.net/grassrootseconomics/visedriver/errors"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/testutil/mocks/httpmocks"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/testutil/mocks/httpmocks"
|
||||||
)
|
)
|
||||||
|
|
||||||
// invalidRequestType is a custom type to test invalid request scenarios
|
// invalidRequestType is a custom type to test invalid request scenarios
|
||||||
@ -165,7 +165,7 @@ func TestDefaultRequestParser_GetSessionId(t *testing.T) {
|
|||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
id, err := parser.GetSessionId(context.Background(),tt.request)
|
id, err := parser.GetSessionId(context.Background(), tt.request)
|
||||||
|
|
||||||
if id != tt.expectedID {
|
if id != tt.expectedID {
|
||||||
t.Errorf("Expected session ID %s, got %s", tt.expectedID, id)
|
t.Errorf("Expected session ID %s, got %s", tt.expectedID, id)
|
||||||
|
@ -4,10 +4,10 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"git.defalsify.org/vise.git/resource"
|
|
||||||
"git.defalsify.org/vise.git/persist"
|
|
||||||
"git.defalsify.org/vise.git/engine"
|
"git.defalsify.org/vise.git/engine"
|
||||||
"git.defalsify.org/vise.git/logging"
|
"git.defalsify.org/vise.git/logging"
|
||||||
|
"git.defalsify.org/vise.git/persist"
|
||||||
|
"git.defalsify.org/vise.git/resource"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,12 +16,12 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type RequestSession struct {
|
type RequestSession struct {
|
||||||
Ctx context.Context
|
Ctx context.Context
|
||||||
Config engine.Config
|
Config engine.Config
|
||||||
Engine engine.Engine
|
Engine engine.Engine
|
||||||
Input []byte
|
Input []byte
|
||||||
Storage *storage.Storage
|
Storage *storage.Storage
|
||||||
Writer io.Writer
|
Writer io.Writer
|
||||||
Continue bool
|
Continue bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ func (c Conns) Set(conn ConnData, typ int8) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c Conns) Have(conn *ConnData) int8 {
|
func (c Conns) Have(conn *ConnData) int8 {
|
||||||
for i := range(_STORETYPE_MAX) {
|
for i := range _STORETYPE_MAX {
|
||||||
ii := int8(i)
|
ii := int8(i)
|
||||||
v, ok := c[ii]
|
v, ok := c[ii]
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -49,8 +49,8 @@ func (c Conns) Have(conn *ConnData) int8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ConnData struct {
|
type ConnData struct {
|
||||||
typ int
|
typ int
|
||||||
str string
|
str string
|
||||||
domain string
|
domain string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ThreadGdbmDb struct {
|
type ThreadGdbmDb struct {
|
||||||
db db.Db
|
db db.Db
|
||||||
connStr string
|
connStr string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ func NewThreadGdbmDb() *ThreadGdbmDb {
|
|||||||
return &ThreadGdbmDb{}
|
return &ThreadGdbmDb{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) Connect(ctx context.Context, connStr string) error {
|
func (tdb *ThreadGdbmDb) Connect(ctx context.Context, connStr string) error {
|
||||||
var ok bool
|
var ok bool
|
||||||
_, ok = dbC[connStr]
|
_, ok = dbC[connStr]
|
||||||
if ok {
|
if ok {
|
||||||
@ -42,18 +42,18 @@ func(tdb *ThreadGdbmDb) Connect(ctx context.Context, connStr string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
dbC[connStr] = make(chan db.Db, 1)
|
dbC[connStr] = make(chan db.Db, 1)
|
||||||
dbC[connStr]<- gdb
|
dbC[connStr] <- gdb
|
||||||
tdb.connStr = connStr
|
tdb.connStr = connStr
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) reserve() {
|
func (tdb *ThreadGdbmDb) reserve() {
|
||||||
if tdb.db == nil {
|
if tdb.db == nil {
|
||||||
tdb.db = <-dbC[tdb.connStr]
|
tdb.db = <-dbC[tdb.connStr]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) release() {
|
func (tdb *ThreadGdbmDb) release() {
|
||||||
if tdb.db == nil {
|
if tdb.db == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -61,57 +61,57 @@ func(tdb *ThreadGdbmDb) release() {
|
|||||||
tdb.db = nil
|
tdb.db = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) SetPrefix(pfx uint8) {
|
func (tdb *ThreadGdbmDb) SetPrefix(pfx uint8) {
|
||||||
tdb.reserve()
|
tdb.reserve()
|
||||||
tdb.db.SetPrefix(pfx)
|
tdb.db.SetPrefix(pfx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) SetSession(sessionId string) {
|
func (tdb *ThreadGdbmDb) SetSession(sessionId string) {
|
||||||
tdb.reserve()
|
tdb.reserve()
|
||||||
tdb.db.SetSession(sessionId)
|
tdb.db.SetSession(sessionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) SetLanguage(lng *lang.Language) {
|
func (tdb *ThreadGdbmDb) SetLanguage(lng *lang.Language) {
|
||||||
tdb.reserve()
|
tdb.reserve()
|
||||||
tdb.db.SetLanguage(lng)
|
tdb.db.SetLanguage(lng)
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) Safe() bool {
|
func (tdb *ThreadGdbmDb) Safe() bool {
|
||||||
tdb.reserve()
|
tdb.reserve()
|
||||||
v := tdb.db.Safe()
|
v := tdb.db.Safe()
|
||||||
tdb.release()
|
tdb.release()
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) Prefix() uint8 {
|
func (tdb *ThreadGdbmDb) Prefix() uint8 {
|
||||||
tdb.reserve()
|
tdb.reserve()
|
||||||
v := tdb.db.Prefix()
|
v := tdb.db.Prefix()
|
||||||
tdb.release()
|
tdb.release()
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) SetLock(typ uint8, locked bool) error {
|
func (tdb *ThreadGdbmDb) SetLock(typ uint8, locked bool) error {
|
||||||
tdb.reserve()
|
tdb.reserve()
|
||||||
err := tdb.db.SetLock(typ, locked)
|
err := tdb.db.SetLock(typ, locked)
|
||||||
tdb.release()
|
tdb.release()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) Put(ctx context.Context, key []byte, val []byte) error {
|
func (tdb *ThreadGdbmDb) Put(ctx context.Context, key []byte, val []byte) error {
|
||||||
tdb.reserve()
|
tdb.reserve()
|
||||||
err := tdb.db.Put(ctx, key, val)
|
err := tdb.db.Put(ctx, key, val)
|
||||||
tdb.release()
|
tdb.release()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) Get(ctx context.Context, key []byte) ([]byte, error) {
|
func (tdb *ThreadGdbmDb) Get(ctx context.Context, key []byte) ([]byte, error) {
|
||||||
tdb.reserve()
|
tdb.reserve()
|
||||||
v, err := tdb.db.Get(ctx, key)
|
v, err := tdb.db.Get(ctx, key)
|
||||||
tdb.release()
|
tdb.release()
|
||||||
return v, err
|
return v, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) Close(ctx context.Context) error {
|
func (tdb *ThreadGdbmDb) Close(ctx context.Context) error {
|
||||||
tdb.reserve()
|
tdb.reserve()
|
||||||
close(dbC[tdb.connStr])
|
close(dbC[tdb.connStr])
|
||||||
delete(dbC, tdb.connStr)
|
delete(dbC, tdb.connStr)
|
||||||
@ -120,28 +120,28 @@ func(tdb *ThreadGdbmDb) Close(ctx context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) Dump(ctx context.Context, key []byte) (*db.Dumper, error) {
|
func (tdb *ThreadGdbmDb) Dump(ctx context.Context, key []byte) (*db.Dumper, error) {
|
||||||
tdb.reserve()
|
tdb.reserve()
|
||||||
defer tdb.release()
|
defer tdb.release()
|
||||||
return tdb.db.Dump(ctx, key)
|
return tdb.db.Dump(ctx, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) DecodeKey(ctx context.Context, key []byte) ([]byte, error) {
|
func (tdb *ThreadGdbmDb) DecodeKey(ctx context.Context, key []byte) ([]byte, error) {
|
||||||
return tdb.db.DecodeKey(ctx, key)
|
return tdb.db.DecodeKey(ctx, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) Abort(ctx context.Context) {
|
func (tdb *ThreadGdbmDb) Abort(ctx context.Context) {
|
||||||
tdb.db.Abort(ctx)
|
tdb.db.Abort(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) Start(ctx context.Context) error {
|
func (tdb *ThreadGdbmDb) Start(ctx context.Context) error {
|
||||||
return tdb.db.Start(ctx)
|
return tdb.db.Start(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) Stop(ctx context.Context) error {
|
func (tdb *ThreadGdbmDb) Stop(ctx context.Context) error {
|
||||||
return tdb.db.Stop(ctx)
|
return tdb.db.Stop(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func(tdb *ThreadGdbmDb) Connection() string {
|
func (tdb *ThreadGdbmDb) Connection() string {
|
||||||
return tdb.db.Connection()
|
return tdb.db.Connection()
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Storage struct {
|
type Storage struct {
|
||||||
Persister *persist.Persister
|
Persister *persist.Persister
|
||||||
UserdataDb db.Db
|
UserdataDb db.Db
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ func NewSimpleStorageProvider(stateStore db.Db, userdataStore db.Db) StorageProv
|
|||||||
pe = pe.WithFlush()
|
pe = pe.WithFlush()
|
||||||
return &SimpleStorageProvider{
|
return &SimpleStorageProvider{
|
||||||
Storage: &Storage{
|
Storage: &Storage{
|
||||||
Persister: pe,
|
Persister: pe,
|
||||||
UserdataDb: userdataStore,
|
UserdataDb: userdataStore,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/jackc/pgx/v5/pgxpool"
|
|
||||||
"git.defalsify.org/vise.git/db"
|
"git.defalsify.org/vise.git/db"
|
||||||
fsdb "git.defalsify.org/vise.git/db/fs"
|
fsdb "git.defalsify.org/vise.git/db/fs"
|
||||||
memdb "git.defalsify.org/vise.git/db/mem"
|
memdb "git.defalsify.org/vise.git/db/mem"
|
||||||
@ -17,6 +16,7 @@ import (
|
|||||||
"git.defalsify.org/vise.git/persist"
|
"git.defalsify.org/vise.git/persist"
|
||||||
"git.defalsify.org/vise.git/resource"
|
"git.defalsify.org/vise.git/resource"
|
||||||
gdbmstorage "git.grassecon.net/grassrootseconomics/visedriver/storage/db/gdbm"
|
gdbmstorage "git.grassecon.net/grassrootseconomics/visedriver/storage/db/gdbm"
|
||||||
|
"github.com/jackc/pgx/v5/pgxpool"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -30,9 +30,9 @@ type StorageService interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MenuStorageService struct {
|
type MenuStorageService struct {
|
||||||
conns Conns
|
conns Conns
|
||||||
poResource resource.Resource
|
poResource resource.Resource
|
||||||
store map[int8]db.Db
|
store map[int8]db.Db
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMenuStorageService(conn Conns) *MenuStorageService {
|
func NewMenuStorageService(conn Conns) *MenuStorageService {
|
||||||
@ -55,7 +55,7 @@ func (ms *MenuStorageService) WithDb(store db.Db, typ int8) *MenuStorageService
|
|||||||
return ms
|
return ms
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ms *MenuStorageService) checkDb(ctx context.Context,typ int8) db.Db {
|
func (ms *MenuStorageService) checkDb(ctx context.Context, typ int8) db.Db {
|
||||||
store := ms.store[typ]
|
store := ms.store[typ]
|
||||||
if store != nil {
|
if store != nil {
|
||||||
return store
|
return store
|
||||||
@ -70,7 +70,7 @@ func (ms *MenuStorageService) checkDb(ctx context.Context,typ int8) db.Db {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
ms.store[typ] = ms.store[v]
|
ms.store[typ] = ms.store[v]
|
||||||
logg.DebugCtxf(ctx, "found existing db", "typ", typ, "srctyp", v, "store", ms.store[typ], "srcstore", ms.store[v])
|
logg.DebugCtxf(ctx, "found existing db", "typ", typ, "srctyp", v, "store", ms.store[typ], "srcstore", ms.store[v], "conn", connData)
|
||||||
return ms.store[typ]
|
return ms.store[typ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ func (ms *MenuStorageService) WithGettext(path string, lns []lang.Language) *Men
|
|||||||
}
|
}
|
||||||
rs := resource.NewPoResource(lns[0], path)
|
rs := resource.NewPoResource(lns[0], path)
|
||||||
|
|
||||||
for _, ln := range(lns) {
|
for _, ln := range lns {
|
||||||
rs = rs.WithLanguage(ln)
|
rs = rs.WithLanguage(ln)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ func (ms *MenuStorageService) ensureDbDir(path string) error {
|
|||||||
func (ms *MenuStorageService) Close(ctx context.Context) error {
|
func (ms *MenuStorageService) Close(ctx context.Context) error {
|
||||||
var errs []error
|
var errs []error
|
||||||
var haveErr bool
|
var haveErr bool
|
||||||
for i := range(_STORETYPE_MAX) {
|
for i := range _STORETYPE_MAX {
|
||||||
err := ms.store[int8(i)].Close(ctx)
|
err := ms.store[int8(i)].Close(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
haveErr = true
|
haveErr = true
|
||||||
@ -237,7 +237,7 @@ func (ms *MenuStorageService) Close(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
if haveErr {
|
if haveErr {
|
||||||
errStr := ""
|
errStr := ""
|
||||||
for i, err := range(errs) {
|
for i, err := range errs {
|
||||||
errStr += fmt.Sprintf("(%d: %v)", i, err)
|
errStr += fmt.Sprintf("(%d: %v)", i, err)
|
||||||
}
|
}
|
||||||
return errors.New(errStr)
|
return errors.New(errStr)
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
|
|
||||||
"git.defalsify.org/vise.git/db"
|
"git.defalsify.org/vise.git/db"
|
||||||
memdb "git.defalsify.org/vise.git/db/mem"
|
memdb "git.defalsify.org/vise.git/db/mem"
|
||||||
"git.defalsify.org/vise.git/resource"
|
|
||||||
"git.defalsify.org/vise.git/persist"
|
"git.defalsify.org/vise.git/persist"
|
||||||
|
"git.defalsify.org/vise.git/resource"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MemStorageService struct {
|
type MemStorageService struct {
|
||||||
@ -39,4 +39,3 @@ func (mss *MemStorageService) GetUserdataDb(ctx context.Context) (db.Db, error)
|
|||||||
func (mss *MemStorageService) GetResource(ctx context.Context) (resource.Resource, error) {
|
func (mss *MemStorageService) GetResource(ctx context.Context) (resource.Resource, error) {
|
||||||
return mss.rs, nil
|
return mss.rs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user