From 0c9444f45bf8777b3ef21850d4839dbb8b10aba0 Mon Sep 17 00:00:00 2001 From: JP Appel Date: Mon, 28 Jul 2025 23:58:07 -0400 Subject: Remove todo contexts --- pkg/server/server.go | 2 +- pkg/server/unix.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'pkg/server') diff --git a/pkg/server/server.go b/pkg/server/server.go index 68750a2..2352f21 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -63,7 +63,7 @@ func NewMux(db *data.Query) *http.ServeMux { return } - pathDocs, err := db.Execute(artifact) + pathDocs, err := db.Execute(r.Context(), artifact) if err != nil { w.WriteHeader(http.StatusInternalServerError) w.Write([]byte("Error executing query")) diff --git a/pkg/server/unix.go b/pkg/server/unix.go index a46320d..9d8c266 100644 --- a/pkg/server/unix.go +++ b/pkg/server/unix.go @@ -6,6 +6,7 @@ import ( "log/slog" "net" "sync" + "time" "github.com/jpappel/atlas/pkg/data" "github.com/jpappel/atlas/pkg/index" @@ -128,15 +129,18 @@ func (s *UnixServer) handleConn(conn *net.UnixConn, id uint64) { break } - docs, err := s.Db.Execute(artifact) + ctx, cancel := context.WithTimeout(context.Background(), 400*time.Millisecond) + docs, err := s.Db.Execute(ctx, artifact) if err != nil { slog.Warn("Failed to execute query", slog.String("query", queryTxt), slog.String("err", err.Error()), ) s.writeError(conn, "query execution error") + cancel() break } + cancel() slog.Debug("Sending results") s.writeResults(conn, docs) -- cgit v1.2.3