server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: CC0-1.0 Imports: 39 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package server serves Taskronin's HTTP API over a private Unix socket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnContext

func ConnContext(ctx context.Context, c net.Conn) context.Context

ConnContext is the http.Server connection hook that captures peer credentials.

func Run

func Run(ctx context.Context, cfg *config.Server, deps Deps) (err error)

Run recovers and serves an instance until cancellation, then drains it while retaining the database and instance lock until all accepted work returns.

Types

type ConnInfo

type ConnInfo struct {
	Transport Transport
	PeerUID   uint32
	PeerPID   int32
	PeerOK    bool           // SO_PEERCRED read succeeded.
	Remote    netip.AddrPort // TCP only.
}

ConnInfo records transport metadata captured when the server accepts a connection.

func ConnInfoFrom

func ConnInfoFrom(ctx context.Context) ConnInfo

ConnInfoFrom returns connection metadata, or its zero value if none was stored.

type Deps

type Deps struct {
	Paths   config.Paths
	Clock   clock.Clock
	Logger  *slog.Logger
	Started func(Startup)
}

Deps supplies the server's environment and optional readiness callback.

type Route

type Route struct {
	Method, Pattern                  string
	Scopes                           domain.Scopes
	OwnerOnly, Exempt, IfMatch, Long bool
	Handler                          http.HandlerFunc
}

Route is the shared routing and scope-matrix description. Authorization is enforced by the service; these flags document each operation's contract.

type Server

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

Server adapts the socket HTTP protocol to the service.

func New

func New(svc *service.Service, conv api.Conv, clk clock.Clock, log *slog.Logger) *Server

New constructs an API server. Nil clock and logger use real time and discard logging.

func (*Server) APIHandler

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

APIHandler returns the socket-only API middleware chain and router.

func (*Server) BeginShutdown

func (s *Server) BeginShutdown()

BeginShutdown cancels long requests; repeated calls are safe.

func (*Server) Routes

func (s *Server) Routes() []Route

Routes returns the API endpoint table. Feature tasks extend this table.

type Startup

type Startup struct {
	Svc     *service.Service
	Socket  string
	WebAddr string
}

Startup exposes the service and actual bound addresses after READY=1.

type Transport

type Transport uint8

Transport identifies the underlying connection type.

const (
	TransportUnix Transport = iota + 1
	TransportTCP
)

Supported connection transports; zero denotes an unknown transport.

Jump to

Keyboard shortcuts

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