server

package
v1.0.0-alpha.7 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 35 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 is the ingest service behind costroid serve: the result-stream and OTLP paths, pricing against the pinned catalog, and the per-PR view.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EgressMain

func EgressMain(ctx context.Context, args []string, stdout, stderr io.Writer) int

EgressMain runs costroid egress and returns an exit code.

func KeysMain

func KeysMain(ctx context.Context, args []string, stdout, stderr io.Writer) int

KeysMain runs costroid keys and returns an exit code.

func Main

func Main(ctx context.Context, args []string, stderr io.Writer) int

Main runs costroid serve until ctx ends and returns an exit code.

Types

type Config

type Config struct {
	Ledger   Ledger
	Verifier TokenVerifier
	Catalog  *catalog.Catalog
	// PseudonymKey is the master key the per-tenant HMAC keys derive from.
	PseudonymKey []byte
	Now          func() time.Time
	Logger       *slog.Logger
}

Config wires a Server.

type Ledger

type Ledger interface {
	TenantForOwner(ctx context.Context, host, owner string) (store.TenantID, error)
	TenantForKey(ctx context.Context, keySHA256 string) (store.TenantID, error)
	Ingest(ctx context.Context, tenant store.TenantID, batch store.Batch) (store.Receipt, error)
	PullRequest(ctx context.Context, tenant store.TenantID, repo, pr string) ([]store.Line, error)
}

Ledger is what the service needs from the store.

type Server

type Server struct {
	Config
}

Server handles ingest and the view.

func New

func New(config Config) *Server

New returns the service. Now and Logger default to the real clock and the default logger.

func (*Server) Handler

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

Handler returns the service's routes.

type TokenVerifier

type TokenVerifier interface {
	Verify(ctx context.Context, token string) (oidc.Identity, error)
}

TokenVerifier checks a CI OIDC token.

Jump to

Keyboard shortcuts

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