httpapi

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package httpapi is the v0.2 production API for non-Go producers (ADR-0008): enqueue tasks and read queue stats over HTTP with token auth. Unlike the read-only dashboard (`tq serve`), this surface WRITES, so the token is mandatory on every bind (no loopback exemption: API servers are meant to be exposed to other machines).

The surface is queue-metadata-only by design (TODO row verified 2026-09-28): enqueue, per-status counts, and health — no per-task reads, so derived outcomes (agent results, review/status verdicts, session usage) remain dashboard surfaces (`tq serve` detail pages, `tq show`).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server is the write API over one store.

func New

func New(store queue.Store, token string, log *slog.Logger) (*Server, error)

New builds a Server. token must be non-empty: the API refuses to start without one (fail closed, unlike the dashboard's loopback exemption).

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the routed, auth-guarded API handler.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context, addr string) error

ListenAndServe starts the API on addr (e.g. "127.0.0.1:8091") until ctx is cancelled. It owns the read model's lifetime when UseReadModel ran: the pump tails the journal for the whole serve window and the projection closes after the HTTP server has fully stopped.

func (*Server) UseReadModel added in v0.3.1

func (s *Server) UseReadModel(ctx context.Context, path string) error

UseReadModel moves the stats read onto the ADR-0019 S3 metaengine read model at path (readmodel.PathFor derives it beside the queue db): the projection folds the journal and GET /api/v1/stats reads its planned table. The enqueue side is untouched — the model is read-only over the store. ListenAndServe owns the model's pump and lifetime; ctx covers the durable-cursor load at setup.

Jump to

Keyboard shortcuts

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