httpserver

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package httpserver is the servicepack service that runs chatz's HTTP API. It self-bootstraps from the environment: parse config, open the DB (running migrations + wiring the generated repositories), build the collaborators (secrets box, model upstreams, MCP manager, auth), and serve the generated StrictServerInterface until the context is cancelled.

Index

Constants

View Source
const ServiceName = "http-server"

ServiceName is the service-manager registration key.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service wires the HTTP API together and owns the resources it opens (the DB handle + the MCP subprocesses/clients), releasing them on Stop. It also runs the internal-only observability listeners (/metrics + pprof) alongside the API, sharing the same metrics registry the usage recorder emits into.

func New

func New() (*Service, error)

New parses config, connects the DB, discovers model upstreams, connects the enabled MCP servers (best-effort), and assembles the HTTP server. It runs when the service manager starts the service (the `run` command), not at registration time — so the DB is only touched when the app actually boots.

func (*Service) Name

func (s *Service) Name() string

Name identifies the service to the service manager.

func (*Service) Run

func (s *Service) Run(ctx context.Context) error

Run serves the HTTP API until ctx is cancelled, at which point Serve drains and shuts down echo and returns nil. The internal observability listeners (/metrics + pprof) run alongside on their own ports and are torn down after the API drains. A failure on an aux port only warns — observability never takes down the API.

func (*Service) Stop

func (s *Service) Stop(ctx context.Context) error

Stop releases the MCP clients (killing stdio subprocesses) and closes the DB handle. MCP close failures only warn — a broken subprocess mustn't block a clean DB shutdown.

Jump to

Keyboard shortcuts

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