httpapi

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package httpapi serves the 2dph brain over HTTP.

Async by design: every request runs on its own goroutine, and CPU-heavy searches are serialized through a bounded worker pool so N requests can't spawn N backends at once.

Used by bin/brain/serve.go. Tests inject a fake API (no exec, no ladybug).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(api API, workers int) http.Handler

func Run

func Run(api API)

Run starts the HTTP server with an injected API (in-process brain, or ExecSearcher).

Types

type API added in v0.4.0

type API interface {
	Search(ctx context.Context, query string, limit int) ([]byte, error)
	Get(ctx context.Context, id string, body bool) ([]byte, error)
	Stats(ctx context.Context) ([]byte, error)
	Audit(ctx context.Context) ([]byte, error)
	Ingest(ctx context.Context) ([]byte, error)
}

API is the in-process brain surface. Production serve.go wires internal/brain.

type ExecSearcher added in v0.4.0

type ExecSearcher struct {
	CmdPath string
	Timeout time.Duration
}

ExecSearcher shells out to var/bin/brain-search. Fallback when the serve binary is built without ladybug cgo (CI / tags=brain_serve only).

func (ExecSearcher) Audit added in v0.4.0

func (ExecSearcher) Audit(context.Context) ([]byte, error)

func (ExecSearcher) Get added in v0.4.0

func (ExecSearcher) Ingest added in v0.4.0

func (ExecSearcher) Ingest(context.Context) ([]byte, error)

func (ExecSearcher) Search added in v0.4.0

func (b ExecSearcher) Search(ctx context.Context, query string, limit int) ([]byte, error)

func (ExecSearcher) Stats added in v0.4.0

func (ExecSearcher) Stats(context.Context) ([]byte, error)

type Server

type Server struct {
	// contains filtered or unexported fields
}

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL