implement missing context
This commit is contained in:
parent
37973a6c9b
commit
ddd8d7cac0
@ -80,7 +80,7 @@ func (hh *HTTPRequestHandler) ServeHTTP(w http.ResponseWriter, req *http.Request
|
|||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
rqs, err = hh.Output(rqs)
|
rqs, err = hh.Output(rqs)
|
||||||
rqs, perr = hh.Reset(rqs)
|
rqs, perr = hh.Reset(rqs.Ctx, rqs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hh.WriteError(w, 500, err)
|
hh.WriteError(w, 500, err)
|
||||||
return
|
return
|
||||||
|
@ -27,16 +27,16 @@ type RequestSession struct {
|
|||||||
|
|
||||||
// TODO: seems like can remove this.
|
// TODO: seems like can remove this.
|
||||||
type RequestParser interface {
|
type RequestParser interface {
|
||||||
GetSessionId(ctx context.Context, rq any) (string, error)
|
GetSessionId(context.Context, any) (string, error)
|
||||||
GetInput(rq any) ([]byte, error)
|
GetInput(any) ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type RequestHandler interface {
|
type RequestHandler interface {
|
||||||
GetConfig() engine.Config
|
GetConfig() engine.Config
|
||||||
GetRequestParser() RequestParser
|
GetRequestParser() RequestParser
|
||||||
GetEngine(cfg engine.Config, rs resource.Resource, pe *persist.Persister) engine.Engine
|
GetEngine(engine.Config, resource.Resource, *persist.Persister) engine.Engine
|
||||||
Process(rs RequestSession) (RequestSession, error)
|
Process(RequestSession) (RequestSession, error)
|
||||||
Output(rs RequestSession) (RequestSession, error)
|
Output(RequestSession) (RequestSession, error)
|
||||||
Reset(rs RequestSession) (RequestSession, error)
|
Reset(context.Context, RequestSession) (RequestSession, error)
|
||||||
Shutdown()
|
Shutdown(ctx context.Context)
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,10 @@ type Storage struct {
|
|||||||
UserdataDb db.Db
|
UserdataDb db.Db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Storage) Close(ctx context.Context) error {
|
||||||
|
return s.UserdataDb.Close(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
type StorageProvider interface {
|
type StorageProvider interface {
|
||||||
Get(sessionId string) (*Storage, error)
|
Get(sessionId string) (*Storage, error)
|
||||||
Put(sessionId string, storage *Storage) error
|
Put(sessionId string, storage *Storage) error
|
||||||
@ -46,5 +50,5 @@ func (p *SimpleStorageProvider) Put(sessionId string, storage *Storage) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *SimpleStorageProvider) Close(ctx context.Context) error {
|
func (p *SimpleStorageProvider) Close(ctx context.Context) error {
|
||||||
return p.Storage.UserdataDb.Close(ctx)
|
return p.Storage.Close(ctx)
|
||||||
}
|
}
|
||||||
|
@ -195,6 +195,7 @@ func (ms *MenuStorageService) ensureDbDir() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: how to handle persister here?
|
||||||
func (ms *MenuStorageService) Close(ctx context.Context) error {
|
func (ms *MenuStorageService) Close(ctx context.Context) error {
|
||||||
errA := ms.stateStore.Close(ctx)
|
errA := ms.stateStore.Close(ctx)
|
||||||
errB := ms.userDataStore.Close(ctx)
|
errB := ms.userDataStore.Close(ctx)
|
||||||
|
Loading…
Reference in New Issue
Block a user