server

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 14 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 Connect translation layer over the transport-neutral service implementations (CONSTRAINTS C13), with one adapter per service and each method a pure unwrap/call/wrap plus the sentinel-to-code mapping in toConnectErr. No business logic lives here, so another transport (grpc-gateway, a real gRPC server) would be a sibling package wrapping the same service/ implementations.

Index

Constants

View Source
const TimingHeader = "Agni-Timing"

TimingHeader is the request header that asks for a request's timing, and the response header that carries it back as a RequestTiming in protojson. A value containing "explain" also asks each query evaluation for its plan, and one containing "memory" asks each stage for the memory as it ended.

Variables

This section is empty.

Functions

func ConnectError added in v0.2.4

func ConnectError(err error) *connect.Error

ConnectError converts a service error to its wire form. It maps the service tier's error sentinels to Connect codes and adds a query's syntax-error position as a detail. An unclassified error is treated as an invalid argument, the service tier's documented default (load/parse failures). The CLI writes a failed request through it under --format json, so a script reading the CLI and a client reading the API see one error shape.

func SlowLine added in v0.2.2

func SlowLine(procedure string, over time.Duration, s timing.Snapshot) string

SlowLine is the log line for one slow request: what took longest, which tier answered each cached read, the slowest rules, and the plan when evaluating a query was the slowest stage.

Types

type API added in v0.2.2

type API struct {
	Workspace *service.WorkspaceService
	Project   *service.ProjectService
	// Snapshot ingests designs, and every other service answers questions about them (agni issue
	// 1061). It must hold the same ProjectResolver as they do, or a question names a snapshot that
	// none of them holds.
	Snapshot *service.SnapshotService
	Design   *service.DesignService
	Check    *service.CheckService
	Diff     *service.DiffService
	Query    *service.QueryService
	Review   *service.ReviewService
	// Timing times the requests that ask, and logs the slow ones (agni issue 914). Its zero value
	// still answers a request that asks with the Agni-Timing header.
	Timing Timing
}

API is the set of services one host serves over Connect. `agni serve` and the wasm engine both register through it, so the two cannot serve different lists of handlers. TableService holds no state, so it has no field here and every host serves it.

func (API) Register added in v0.2.2

func (a API) Register(mux *http.ServeMux, queryOpts ...connect.HandlerOption) []string

Register mounts every service on mux and returns the paths it registered, in a fixed order. queryOpts apply to the services that evaluate queries (check, query, review). A deployment's query budget attaches to those services.

type Budget added in v0.2.2

type Budget struct {
	// Enforce caps each evaluation's work. Zero enforces nothing, so a deployment can watch what its
	// queries cost (Warn) before it chooses a cap.
	Enforce int64
	// Warn is the work above which a query is logged with its cost and a suggested cap. Zero logs
	// nothing.
	Warn int64
	// Log receives each line. Nil discards them.
	Log func(format string, args ...any)
}

Budget is the work budget a server applies to every query it evaluates, and how it reports the queries that cost the most (agni issue 792). Work is what a fact base counts. It counts candidate comparisons, each row a generator emits, and the connections a circuit walk examines.

func (Budget) Interceptor added in v0.2.2

func (b Budget) Interceptor() connect.UnaryInterceptorFunc

Interceptor sets the budget on every request's context. The request's queries and query-backed rules read it there. A request may narrow the budget but never raise it. Interceptor also logs each query whose reported work passes Warn, and each one the budget stopped.

type Check

type Check struct {
	webapiconnect.UnimplementedCheckServiceHandler
	// contains filtered or unexported fields
}

Check adapts service.CheckService to the generated Connect handler interface.

func NewCheck

func NewCheck(svc *service.CheckService) *Check

NewCheck wraps svc for Connect.

func (*Check) RenderCheckReport added in v0.2.2

type Design

type Design struct {
	webapiconnect.UnimplementedDesignServiceHandler
	// contains filtered or unexported fields
}

Design adapts service.DesignService to the generated Connect handler interface.

func NewDesign

func NewDesign(svc *service.DesignService) *Design

NewDesign wraps svc for Connect.

func (*Design) ListWalkKinds added in v0.6.0

func (*Design) LocateSubjects added in v0.5.0

func (*Design) TraceDesign added in v0.2.0

func (*Design) WalkDesign added in v0.6.0

type Diff

type Diff struct {
	webapiconnect.UnimplementedDiffServiceHandler
	// contains filtered or unexported fields
}

Diff adapts service.DiffService to the generated Connect handler interface.

func NewDiff

func NewDiff(svc *service.DiffService) *Diff

NewDiff wraps svc for Connect.

type Lexicon added in v0.4.0

type Lexicon struct {
	webapiconnect.UnimplementedLexiconServiceHandler
	// contains filtered or unexported fields
}

Lexicon adapts service.LexiconService to the generated Connect handler interface.

func NewLexicon added in v0.4.0

func NewLexicon(svc *service.LexiconService) *Lexicon

NewLexicon wraps svc for Connect.

func (*Lexicon) CompareLexicons added in v0.4.0

func (*Lexicon) ExplainNet added in v0.4.0

func (*Lexicon) GetLexicon added in v0.4.0

func (*Lexicon) RenderConvention added in v0.4.0

type Project added in v0.2.0

type Project struct {
	webapiconnect.UnimplementedProjectServiceHandler
	// contains filtered or unexported fields
}

Project adapts service.ProjectService to the generated Connect handler interface.

func NewProject added in v0.2.0

func NewProject(svc *service.ProjectService) *Project

NewProject wraps svc for Connect.

func (*Project) GetDesign added in v0.2.0

func (*Project) GetProject added in v0.2.0

func (*Project) ListProjects added in v0.2.0

func (*Project) ResolveDesign added in v0.2.0

type Query

type Query struct {
	webapiconnect.UnimplementedQueryServiceHandler
	// contains filtered or unexported fields
}

Query adapts service.QueryService to the generated Connect handler interface.

func NewQuery

func NewQuery(svc *service.QueryService) *Query

NewQuery wraps svc for Connect.

func (*Query) ListQuerySets added in v0.2.2

func (*Query) ParseQuerySet added in v0.2.2

func (*Query) RunQueries added in v0.2.2

type Review

type Review struct {
	webapiconnect.UnimplementedReviewServiceHandler
	// contains filtered or unexported fields
}

Review adapts service.ReviewService to the generated Connect handler interface.

func NewReview

func NewReview(svc *service.ReviewService) *Review

NewReview wraps svc for Connect.

func (*Review) CreateReview added in v0.2.0

func (*Review) DeleteReview added in v0.2.0

func (*Review) GetReview added in v0.2.0

func (*Review) GetReviewManifest added in v0.2.0

func (*Review) ListChecklists added in v0.2.2

func (*Review) ListReviews added in v0.2.0

func (*Review) RenderReviewReport added in v0.2.2

type Snapshot added in v0.3.0

type Snapshot struct {
	webapiconnect.UnimplementedSnapshotServiceHandler
	// contains filtered or unexported fields
}

Snapshot adapts service.SnapshotService to the generated Connect handler interface.

func NewSnapshot added in v0.3.0

func NewSnapshot(svc *service.SnapshotService) *Snapshot

NewSnapshot wraps svc for Connect.

func (*Snapshot) DeleteSnapshot added in v0.3.0

func (*Snapshot) GetSnapshot added in v0.3.0

func (*Snapshot) Ingest added in v0.3.0

func (*Snapshot) ListSnapshots added in v0.3.0

func (*Snapshot) UpdateSnapshot added in v0.3.0

func (*Snapshot) UploadBlobs added in v0.3.0

type Table added in v0.2.2

type Table struct {
	webapiconnect.UnimplementedTableServiceHandler
	// contains filtered or unexported fields
}

Table adapts service.TableService to the generated Connect handler interface.

func NewTable added in v0.2.2

func NewTable() *Table

NewTable wraps the projection service for Connect. It holds no state, so it takes none.

func (*Table) Encode added in v0.2.2

func (*Table) Tabulate added in v0.2.2

type Timing added in v0.2.2

type Timing struct {
	// Slow logs every request that takes longer, with the stage that took the most, the tier that
	// answered each cached read, the slowest rules, and the plan when evaluation was the slowest
	// stage. Zero logs nothing.
	Slow time.Duration
	// Log receives each line. Nil discards them.
	Log func(format string, args ...any)
}

Timing times requests and reports where their time went (agni issue 914). A request is timed when it asks (the Agni-Timing header) or when Slow is set, and a request that asked gets its breakdown in the Agni-Timing and Server-Timing response headers.

func (Timing) Interceptor added in v0.2.2

func (t Timing) Interceptor() connect.UnaryInterceptorFunc

Interceptor returns the timing interceptor. A request that neither asks nor could be slow-logged passes straight through.

type ViewerRoom added in v0.3.9

type ViewerRoom struct {
	webapiconnect.UnimplementedViewerRoomServiceHandler
	// contains filtered or unexported fields
}

ViewerRoom adapts service.ViewerRoomService to the generated Connect handler interface. `agni serve` registers it only under --viewer-rooms (agni issue 1154), so it is not part of API.

func NewViewerRoom added in v0.3.9

func NewViewerRoom(svc *service.ViewerRoomService) *ViewerRoom

NewViewerRoom wraps svc for Connect.

func (*ViewerRoom) JoinViewerRoom added in v0.3.9

type Workspace

type Workspace struct {
	webapiconnect.UnimplementedWorkspaceServiceHandler
	// contains filtered or unexported fields
}

Workspace adapts service.WorkspaceService to the generated Connect handler interface. The embedded Unimplemented handler keeps newly generated RPCs returning CodeUnimplemented until wired, so adding a proto method never breaks the build.

func NewWorkspace

func NewWorkspace(svc *service.WorkspaceService) *Workspace

NewWorkspace wraps svc for Connect.

func (*Workspace) DeclareCompanion added in v0.5.0

func (*Workspace) ListDesignFiles added in v0.2.2

func (*Workspace) ProposeDesigns added in v0.2.2

Jump to

Keyboard shortcuts

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