From 6c485489bfdfbfb047e601e21599c4c31f45511d Mon Sep 17 00:00:00 2001 From: Mathias Bergqvist Date: Fri, 17 Apr 2026 20:16:59 +0200 Subject: [PATCH] chore: scaffold ingestion Go module --- ingestion/cmd/server/main.go | 37 ++++++++++++++++++++++++++++++++++++ ingestion/go.mod | 11 +++++++++++ ingestion/go.sum | 6 ++++++ 3 files changed, 54 insertions(+) create mode 100644 ingestion/cmd/server/main.go create mode 100644 ingestion/go.mod create mode 100644 ingestion/go.sum diff --git a/ingestion/cmd/server/main.go b/ingestion/cmd/server/main.go new file mode 100644 index 0000000..98e7e8d --- /dev/null +++ b/ingestion/cmd/server/main.go @@ -0,0 +1,37 @@ +// ingestion/cmd/server/main.go +package main + +import ( + "log/slog" + "net/http" + "os" + + "github.com/mathiasbq/hyperguild/ingestion/internal/api" +) + +func main() { + logger := slog.New(slog.NewJSONHandler(os.Stdout, nil)) + + brainDir := os.Getenv("INGEST_BRAIN_DIR") + if brainDir == "" { + brainDir = "../brain" + } + + port := os.Getenv("INGEST_PORT") + if port == "" { + port = "3300" + } + + h := api.NewHandler(brainDir, logger) + + mux := http.NewServeMux() + mux.HandleFunc("/query", h.Query) + mux.HandleFunc("/write", h.Write) + + addr := ":" + port + logger.Info("ingestion server starting", "addr", addr, "brain_dir", brainDir) + if err := http.ListenAndServe(addr, mux); err != nil { + logger.Error("server stopped", "err", err) + os.Exit(1) + } +} diff --git a/ingestion/go.mod b/ingestion/go.mod new file mode 100644 index 0000000..c13d6a2 --- /dev/null +++ b/ingestion/go.mod @@ -0,0 +1,11 @@ +module github.com/mathiasbq/hyperguild/ingestion + +go 1.26.1 + +require github.com/stretchr/testify v1.11.1 + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/ingestion/go.sum b/ingestion/go.sum new file mode 100644 index 0000000..aa256bf --- /dev/null +++ b/ingestion/go.sum @@ -0,0 +1,6 @@ +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=