Pre-D5: extract CatalogClient to internal/catalogclient/ + add List
queryd (D5) needs the same HTTP client to catalogd that ingestd uses, but the client lived in internal/ingestd — having queryd import from ingestd would invert the data-flow direction (ingestd is upstream of queryd; the package dep should not point back). Extract to a shared internal/catalogclient/ package now, before D5 forces it under implementation pressure. Adds the List(ctx) method queryd will need for view registration. Unit tests cover Register success/conflict and List success/error paths against an httptest.Server fake. ingestd's import flips from internal/ingestd → internal/catalogclient; the wire format and behavior are unchanged. All four smokes (D1/D2/D3/ D4) PASS unchanged. DuckDB cgo path re-verified with the official github.com/duckdb/duckdb-go/v2 (per ADR-001) on Go 1.25 + arrow-go. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+7
-6
@@ -1,8 +1,8 @@
|
||||
// ingestd is the data on-ramp: CSV in (multipart form), Parquet out
|
||||
// (to storaged), manifest registered (with catalogd). One round trip
|
||||
// of HTTP, two service hops. The interesting glue lives in
|
||||
// internal/ingestd/{schema,csv,catalog_client}.go; main.go just wires
|
||||
// the route and threads the upstream URLs through.
|
||||
// internal/ingestd/{schema,csv}.go and internal/catalogclient/;
|
||||
// main.go just wires the route and threads the upstream URLs through.
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
|
||||
"git.agentview.dev/profit/golangLAKEHOUSE/internal/catalogclient"
|
||||
"git.agentview.dev/profit/golangLAKEHOUSE/internal/catalogd"
|
||||
"git.agentview.dev/profit/golangLAKEHOUSE/internal/ingestd"
|
||||
"git.agentview.dev/profit/golangLAKEHOUSE/internal/shared"
|
||||
@@ -54,7 +55,7 @@ func main() {
|
||||
|
||||
h := &handlers{
|
||||
storagedURL: strings.TrimRight(cfg.Ingestd.StoragedURL, "/"),
|
||||
catalogd: ingestd.NewCatalogClient(cfg.Ingestd.CatalogdURL),
|
||||
catalogd: catalogclient.New(cfg.Ingestd.CatalogdURL),
|
||||
hc: &http.Client{Timeout: 5 * time.Minute},
|
||||
}
|
||||
|
||||
@@ -66,7 +67,7 @@ func main() {
|
||||
|
||||
type handlers struct {
|
||||
storagedURL string
|
||||
catalogd *ingestd.CatalogClient
|
||||
catalogd *catalogclient.Client
|
||||
hc *http.Client
|
||||
}
|
||||
|
||||
@@ -136,13 +137,13 @@ func (h *handlers) handleIngest(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// 3. Register with catalogd
|
||||
rc := res.RowCount
|
||||
regResp, err := h.catalogd.Register(r.Context(), &ingestd.RegisterRequest{
|
||||
regResp, err := h.catalogd.Register(r.Context(), &catalogclient.RegisterRequest{
|
||||
Name: name,
|
||||
SchemaFingerprint: fingerprint,
|
||||
Objects: []catalogd.Object{{Key: parquetKey, Size: int64(len(res.Parquet))}},
|
||||
RowCount: &rc,
|
||||
})
|
||||
if errors.Is(err, ingestd.ErrFingerprintConflict) {
|
||||
if errors.Is(err, catalogclient.ErrFingerprintConflict) {
|
||||
http.Error(w, err.Error(), http.StatusConflict)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user