grpcserver

package
v0.0.0-...-90b817e Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 64 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBindAddress    = ":8083"
	DefaultMaxMessageSize = client.DefaultGRPCMaxMessageSize
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	SandboxService         *sandbox.Service
	BindAddress            string
	MaxMessageBytes        int
	Reflection             bool
	TLSCertFile            string
	TLSKeyFile             string
	Authenticator          auth.AuthProvider
	RuntimeAuthenticator   auth.AuthProvider
	ShareStore             sessionsvc.ShareStore
	AgentService           *kubecrud.Service[*v1alpha3.Agent, *v1alpha3.AgentList]
	AgentTemplateService   *kubecrud.Service[*v1alpha3.AgentTemplate, *v1alpha3.AgentTemplateList]
	HarnessService         *kubecrud.Service[*v1alpha3.Harness, *v1alpha3.HarnessList]
	ModelService           *modelservice.Service
	ToolService            *toolservice.Service
	PromptTemplateService  *prompttemplateservice.Service
	SystemService          *systemservice.Service
	MemoryService          *memoryservice.Service
	TaskStoreService       *taskstore.Service
	SessionService         *sessionsvc.Service
	CheckpointService      *checkpoint.Service
	ScheduledRunService    *scheduledrun.Service
	A2AHandler             a2asrv.RequestHandler
	SandboxTemplateService *kubecrud.Service[*v1alpha3.SandboxTemplate, *v1alpha3.SandboxTemplateList]
	// RegisterServices registers services core does not own. Called during New,
	// because gRPC requires every service to be registered before Serve.
	RegisterServices func(grpc.ServiceRegistrar)
	MethodPolicies   MethodPolicies
	Listener         net.Listener
	HTTPHandler      http.Handler
}

type MethodPolicies

type MethodPolicies map[string]auth.AccessMode

func DefaultMethodPolicies

func DefaultMethodPolicies() MethodPolicies

type Server

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

func New

func New(config Config) (*Server, error)

func (*Server) HandlerOr

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

HandlerOr routes native gRPC and gRPC-Web requests to the services and everything else to next.

This is the one statement of the rule so callers do not duplicate routing behavior. The controller composes its HTTP handler through here.

Two things it settles that are easy to get wrong:

Requests are told apart by content type rather than by path, so the service names never have to be restated. And a leading `/api` is stripped, because the wrapper matches the gRPC path a generated client sends — `/<package>.<Service>/<Method>` — while the chart's nginx serves the whole API under /api on the UI's own origin. That prefix is where a same-origin browser has to address it from and nowhere the wrapper can be told about.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

func (*Server) WebHandler

func (s *Server) WebHandler() *grpcweb.WrappedGrpcServer

WebHandler exposes the same services over gRPC-Web.

A browser cannot speak gRPC. The protocol needs HTTP/2 trailers, and `fetch` gives a page no way to read them, which is why the services registered in New() are unreachable from a page however the network is arranged. gRPC-Web carries the same frames over HTTP/1.1 with the trailers moved into the body, so this wrapper is what makes this API callable from a browser at all.

Wrapping is deliberately all it does: the returned handler serves the very server built in New(), so a service registered there is reachable both ways and the interceptor chain — authentication included — runs identically for a call arriving either way. Nothing here decides who may call what.

Most callers want HandlerOr, which also says what to do with everything that is not a gRPC-Web request.

Jump to

Keyboard shortcuts

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