Ensure db close on http signal shutdown, correct stores to provider
This commit is contained in:
@@ -66,6 +66,13 @@ func(f *SessionHandler) writeError(w http.ResponseWriter, code int, msg string,
|
||||
return
|
||||
}
|
||||
|
||||
func(f* SessionHandler) Shutdown() {
|
||||
err := f.provider.Close()
|
||||
if err != nil {
|
||||
logg.Errorf("handler shutdown error", "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
func(f *SessionHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
var r bool
|
||||
sessionId, err := f.rp.GetSessionId(req)
|
||||
@@ -89,6 +96,7 @@ func(f *SessionHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
f.writeError(w, 500, "Storage retrieval fail", err)
|
||||
return
|
||||
}
|
||||
defer f.provider.Put(cfg.SessionId, storage)
|
||||
en := getEngine(cfg, f.rs, storage.Persister)
|
||||
en = en.WithFirst(f.first)
|
||||
if cfg.EngineDebug {
|
||||
|
||||
@@ -39,5 +39,5 @@ func (p *SimpleStorageProvider) Put(sessionId string, storage Storage) error {
|
||||
}
|
||||
|
||||
func (p *SimpleStorageProvider) Close() error {
|
||||
return nil
|
||||
return p.Storage.UserdataDb.Close()
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ func PackKey(typ DataTyp, data []byte) []byte {
|
||||
}
|
||||
|
||||
func ReadEntry(ctx context.Context, store db.Db, sessionId string, typ DataTyp) ([]byte, error) {
|
||||
|
||||
store.SetPrefix(db.DATATYPE_USERDATA)
|
||||
store.SetSession(sessionId)
|
||||
k := PackKey(typ, []byte(sessionId))
|
||||
|
||||
Reference in New Issue
Block a user