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
- func ConnectError(err error) *connect.Error
- func SlowLine(procedure string, over time.Duration, s timing.Snapshot) string
- type API
- type Budget
- type Check
- func (a *Check) CheckDesign(ctx context.Context, req *connect.Request[webapi.CheckDesignRequest]) (*connect.Response[webapi.CheckDesignResponse], error)
- func (a *Check) GetCheckReport(ctx context.Context, req *connect.Request[webapi.GetCheckReportRequest]) (*connect.Response[webapi.GetCheckReportResponse], error)
- func (a *Check) GetComponentParams(ctx context.Context, req *connect.Request[webapi.GetComponentParamsRequest]) (*connect.Response[webapi.GetComponentParamsResponse], error)
- func (a *Check) GetExpectations(ctx context.Context, req *connect.Request[webapi.GetExpectationsRequest]) (*connect.Response[webapi.GetExpectationsResponse], error)
- func (a *Check) GetInterfaceCoverage(ctx context.Context, req *connect.Request[webapi.GetInterfaceCoverageRequest]) (*connect.Response[webapi.GetInterfaceCoverageResponse], error)
- func (a *Check) GetNamingConvention(ctx context.Context, req *connect.Request[webapi.GetNamingConventionRequest]) (*connect.Response[webapi.GetNamingConventionResponse], error)
- func (a *Check) ListRules(ctx context.Context, req *connect.Request[webapi.ListRulesRequest]) (*connect.Response[webapi.ListRulesResponse], error)
- func (a *Check) RenderCheckReport(ctx context.Context, req *connect.Request[webapi.RenderCheckReportRequest]) (*connect.Response[webapi.RenderCheckReportResponse], error)
- type Design
- func (a *Design) GetDesign(ctx context.Context, req *connect.Request[webapi.GetDesignRequest]) (*connect.Response[webapi.GetDesignResponse], error)
- func (a *Design) GetLayoutReport(ctx context.Context, req *connect.Request[webapi.GetLayoutReportRequest]) (*connect.Response[webapi.GetLayoutReportResponse], error)
- func (a *Design) GetSheet(ctx context.Context, req *connect.Request[webapi.GetSheetRequest]) (*connect.Response[webapi.GetSheetResponse], error)
- func (a *Design) HighlightSheet(ctx context.Context, req *connect.Request[webapi.HighlightSheetRequest]) (*connect.Response[webapi.HighlightSheetResponse], error)
- func (a *Design) TraceDesign(ctx context.Context, req *connect.Request[webapi.TraceDesignRequest]) (*connect.Response[webapi.TraceDesignResponse], error)
- type Diff
- type Project
- func (a *Project) GetDesign(ctx context.Context, req *connect.Request[webapi.GetProjectDesignRequest]) (*connect.Response[webapi.Design], error)
- func (a *Project) GetProject(ctx context.Context, req *connect.Request[webapi.GetProjectRequest]) (*connect.Response[webapi.Project], error)
- func (a *Project) ListDesigns(ctx context.Context, req *connect.Request[webapi.ListProjectDesignsRequest]) (*connect.Response[webapi.ListProjectDesignsResponse], error)
- func (a *Project) ListProjects(ctx context.Context, req *connect.Request[webapi.ListProjectsRequest]) (*connect.Response[webapi.ListProjectsResponse], error)
- func (a *Project) ResolveDesign(ctx context.Context, req *connect.Request[webapi.ResolveDesignRequest]) (*connect.Response[webapi.ResolveDesignResponse], error)
- type Query
- func (a *Query) ListQuerySets(ctx context.Context, req *connect.Request[webapi.ListQuerySetsRequest]) (*connect.Response[webapi.ListQuerySetsResponse], error)
- func (a *Query) ListRelations(ctx context.Context, req *connect.Request[webapi.ListRelationsRequest]) (*connect.Response[webapi.ListRelationsResponse], error)
- func (a *Query) ParseQuerySet(ctx context.Context, req *connect.Request[webapi.ParseQuerySetRequest]) (*connect.Response[webapi.ParseQuerySetResponse], error)
- func (a *Query) RunQueries(ctx context.Context, req *connect.Request[webapi.RunQueriesRequest]) (*connect.Response[webapi.RunQueriesResponse], error)
- func (a *Query) RunQuery(ctx context.Context, req *connect.Request[webapi.RunQueryRequest]) (*connect.Response[webapi.RunQueryResponse], error)
- type Review
- func (a *Review) CreateReview(ctx context.Context, req *connect.Request[webapi.CreateReviewRequest]) (*connect.Response[webapi.Review], error)
- func (a *Review) DeleteReview(ctx context.Context, req *connect.Request[webapi.DeleteReviewRequest]) (*connect.Response[emptypb.Empty], error)
- func (a *Review) GetReview(ctx context.Context, req *connect.Request[webapi.GetReviewRequest]) (*connect.Response[webapi.Review], error)
- func (a *Review) GetReviewManifest(ctx context.Context, req *connect.Request[webapi.GetReviewManifestRequest]) (*connect.Response[webapi.GetReviewManifestResponse], error)
- func (a *Review) ListChecklists(ctx context.Context, req *connect.Request[webapi.ListChecklistsRequest]) (*connect.Response[webapi.ListChecklistsResponse], error)
- func (a *Review) ListReviews(ctx context.Context, req *connect.Request[webapi.ListReviewsRequest]) (*connect.Response[webapi.ListReviewsResponse], error)
- func (a *Review) RenderReviewReport(ctx context.Context, req *connect.Request[webapi.RenderReviewReportRequest]) (*connect.Response[webapi.RenderReviewReportResponse], error)
- type Snapshot
- func (a *Snapshot) DeleteSnapshot(ctx context.Context, req *connect.Request[webapi.DeleteSnapshotRequest]) (*connect.Response[emptypb.Empty], error)
- func (a *Snapshot) GetSnapshot(ctx context.Context, req *connect.Request[webapi.GetSnapshotRequest]) (*connect.Response[webapi.Snapshot], error)
- func (a *Snapshot) Ingest(ctx context.Context, req *connect.Request[webapi.IngestRequest]) (*connect.Response[webapi.Snapshot], error)
- func (a *Snapshot) ListSnapshots(ctx context.Context, req *connect.Request[webapi.ListSnapshotsRequest]) (*connect.Response[webapi.ListSnapshotsResponse], error)
- func (a *Snapshot) UpdateSnapshot(ctx context.Context, req *connect.Request[webapi.UpdateSnapshotRequest]) (*connect.Response[webapi.Snapshot], error)
- func (a *Snapshot) UploadBlobs(ctx context.Context, req *connect.Request[webapi.UploadBlobsRequest]) (*connect.Response[webapi.UploadBlobsResponse], error)
- type Table
- type Timing
- type Workspace
- func (a *Workspace) ListDesignFiles(ctx context.Context, req *connect.Request[webapi.ListDesignFilesRequest]) (*connect.Response[webapi.ListDesignFilesResponse], error)
- func (a *Workspace) ListDir(ctx context.Context, req *connect.Request[webapi.ListDirRequest]) (*connect.Response[webapi.ListDirResponse], error)
- func (a *Workspace) ListMounts(ctx context.Context, req *connect.Request[webapi.ListMountsRequest]) (*connect.Response[webapi.ListMountsResponse], error)
- func (a *Workspace) ProposeDesigns(ctx context.Context, req *connect.Request[webapi.ProposeDesignsRequest]) (*connect.Response[webapi.ProposeDesignsResponse], error)
Constants ¶
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
ConnectError is a service error as the wire carries it: the service tier's error sentinels mapped to Connect codes, with 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.
Types ¶
type API ¶ added in v0.2.2
type API struct {
Workspace *service.WorkspaceService
Project *service.ProjectService
// Snapshot ingests the designs every other service answers about (agni issue 1061). It must hold
// the same ProjectResolver they do, or a question names a snapshot 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.
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 the unit a fact base 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, where every query and every query-backed rule the request evaluates reads it (a request may narrow it, never raise it), and logs each query whose reported work passes Warn and each one stopped by the budget.
type Check ¶
type Check struct {
webapiconnect.UnimplementedCheckServiceHandler
// contains filtered or unexported fields
}
Check adapts service.CheckService to the generated Connect handler interface.
func (*Check) CheckDesign ¶
func (*Check) GetCheckReport ¶
func (*Check) GetComponentParams ¶
func (*Check) GetExpectations ¶
func (*Check) GetInterfaceCoverage ¶
func (*Check) GetNamingConvention ¶ added in v0.2.0
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) GetLayoutReport ¶
func (*Design) HighlightSheet ¶
func (*Design) TraceDesign ¶ added in v0.2.0
type Diff ¶
type Diff struct {
webapiconnect.UnimplementedDiffServiceHandler
// contains filtered or unexported fields
}
Diff adapts service.DiffService to the generated Connect handler interface.
func (*Diff) DiffDesigns ¶
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) GetProject ¶ added in v0.2.0
func (*Project) ListDesigns ¶ 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 (*Query) ListQuerySets ¶ added in v0.2.2
func (*Query) ListRelations ¶
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) 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) 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.
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 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.