api

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 41 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 api is fleetwire's HTTP API: the tenant and operator API on the public listener, and enrollment and renewal on the device listener.

Routing uses the standard library's method patterns (ADR-0011). Every error is an RFC 9457 problem; every list is paged with signed cursors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	PublicAddr string
	DeviceAddr string
	PublicTLS  *tls.Config
	// DeviceTLS must request (not require) client certificates: enrollment
	// has none yet, renewal needs one.
	DeviceTLS *tls.Config
	// CABundlePEM is what devices trust for the broker and the API.
	CABundlePEM  []byte
	BrokerURL    string
	DeviceAPIURL string

	RatePerSecond float64
	RateBurst     int
	// AuthFailPerSecond and AuthFailBurst bound failed token lookups per
	// client network. A network over the budget is refused before its
	// tokens reach the database.
	AuthFailPerSecond float64
	AuthFailBurst     int
	// EnrollPerSecond and EnrollBurst limit enrollment and CRL requests
	// per client network.
	EnrollPerSecond float64
	EnrollBurst     int
	EnrollTokenTTL  time.Duration
	ExportDir       string
	// MaxActiveExports caps a tenant's pending and running exports.
	MaxActiveExports int
	// ReadingsScanChunks is the most chunks one readings page decrypts
	// (default 2000).
	ReadingsScanChunks int
}

Config is the API's own settings.

type Deps

type Deps struct {
	DB        *store.DB
	Keyring   keyring.Keyring
	Keys      *tenantkey.Manager
	DeviceCA  *pki.CA
	CRL       *crl.Publisher
	CursorKey []byte
	Log       *slog.Logger
	Registry  prometheus.Registerer
}

Deps are the API's collaborators.

type Server

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

Server serves the API.

func New

func New(cfg Config, d Deps) *Server

New builds a server.

func (*Server) DeviceHandler

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

DeviceHandler serves enrollment and renewal.

func (*Server) PublicHandler

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

PublicHandler serves the tenant and operator API.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, untilDrained ...func(context.Context)) error

Serve runs both listeners until ctx ends, then shuts down gracefully. untilDrained run until both listeners have drained, as the token use recorder does, so work a request still running at shutdown hands over to them is still done: the API passes the CRL publisher, which must publish a revocation made by such a request. Serve returns once they stopped.

Directories

Path Synopsis
Package apitest runs a real fleetwire API for tests: real PostgreSQL, the real dev PKI, real TLS listeners, and the real job worker.
Package apitest runs a real fleetwire API for tests: real PostgreSQL, the real dev PKI, real TLS listeners, and the real job worker.

Jump to

Keyboard shortcuts

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