httpapi

package
v0.3.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 server 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 (a counting semaphore) so N requests can't spawn N search processes at once.

Used by bin/brain/serve.go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(searcher Searcher, workers int) http.Handler

func Run

func Run()

Run starts the HTTP server. Reads env: KB_SEARCH_CMD (default $KB_ROOT/var/bin/brain-search), KB_WORKERS (default 4), KB_PORT (default 8630).

Types

type Searcher

type Searcher interface {
	Search(ctx context.Context, query string, limit int) ([]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