From 02b54de9c4f391f75eb8287e3857ecda30d483a4 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Fri, 05 Sep 2025 13:28:54 +0000 Subject: [PATCH] appview/db: close once done Signed-off-by: oppiliappan --- appview/db/db.go | 4 ++++ appview/state/state.go | 5 +++++ cmd/appview/main.go | 3 +++ 3 file(s) changed, 12 insertion(s)(+), 0 deletion(s)(-) diff --git a/appview/db/db.go b/appview/db/db.go --- a/appview/db/db.go +++ b/appview/db/db.go @@ -749,6 +749,10 @@ return nil } +func (d *DB) Close() error { + return d.DB.Close() +} + type filter struct { key string arg any diff --git a/appview/state/state.go b/appview/state/state.go --- a/appview/state/state.go +++ b/appview/state/state.go @@ -165,6 +165,11 @@ return state, nil } +func (s *State) Close() error { + // other close up logic goes here + return s.db.Close() +} + func (s *State) Favicon(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "image/svg+xml") w.Header().Set("Cache-Control", "public, max-age=31536000") // one year diff --git a/cmd/appview/main.go b/cmd/appview/main.go --- a/cmd/appview/main.go +++ b/cmd/appview/main.go @@ -23,6 +23,9 @@ } state, err := state.Make(ctx, c) + defer func() { + log.Println(state.Close()) + }() if err != nil { log.Fatal(err) -- tangled.sh