server

package
v1.0.0-alpha.6 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 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 hosts the Ferret Wire protocol through managed TCP serving or caller-created listeners, over a borrowed caller-configured Unified API runtime. Construction never opens a listener. Host credentials and middleware apply to both serving paths; without credentials there is no encryption or authentication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limits

type Limits struct {
	MaxConnections                int
	MaxPlansPerConnection         int
	MaxSessionsPerConnection      int
	MaxExecutionsPerConnection    int
	MaxDebugSessionsPerConnection int
	MaxWatchersPerResource        int
	MaxBreakpointsPerDebugSession int
	MaxInboundMessageBytes        int
	MaxOutboundMessageBytes       int
}

Limits bounds all client-controlled resource and message classes. A custom value replaces the complete default set and every field must be positive.

func DefaultLimits

func DefaultLimits() Limits

DefaultLimits returns the secure finite limits used by New.

type Option

type Option func(*config) error

Option configures a Server without transferring host ownership. New applies every non-nil option in registration order and joins failures. Nil functions are rejected before server construction. Factory validation failures expose gooptions.ValidationError through errors.As.

func WithLimits

func WithLimits(limits Limits) Option

WithLimits replaces the complete default limit set. New rejects the option when any resource or message limit is not positive, reporting every invalid field without applying a partial replacement. Validation errors use relative field-key labels; their order is unspecified.

func WithRuntimeIdentity

func WithRuntimeIdentity(identity RuntimeIdentity) Option

WithRuntimeIdentity publishes optional host application identity during the Connect handshake. Name is required; Wire does not derive identity from the process or environment.

func WithStreamInterceptors

func WithStreamInterceptors(interceptors ...grpc.StreamServerInterceptor) Option

WithStreamInterceptors appends host middleware for every streaming RPC, inside Wire's sanitized recovery boundary. Nil entries are rejected by New. Validation errors identify entries by relative index and omit the list value. The interceptor list is copied; middleware itself must support concurrent calls. Authentication here applies at stream establishment; later revocation is host policy. Framed output responses use identity compression, selected before middleware; interceptors must preserve that selection, including when sending early headers.

func WithTransportCredentials

func WithTransportCredentials(creds credentials.TransportCredentials) Option

WithTransportCredentials sets the host's gRPC transport policy for both Run and Serve. New rejects nil credentials. Repeated options use the last value. Without credentials, Wire provides no transport encryption or authentication.

func WithUnaryInterceptors

func WithUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor) Option

WithUnaryInterceptors appends host middleware for every unary RPC, inside Wire's sanitized recovery boundary. Nil entries are rejected by New. Middleware must preserve the identity encoding selected for Variables responses. Validation errors identify entries by relative index and omit the list value. The interceptor list is copied; middleware itself must support concurrent calls.

type RunOption

type RunOption func(*runConfig) error

RunOption configures managed shutdown without changing constructor policy. Run applies every non-nil option in registration order and joins failures. Nil functions are rejected before startup reservation or listening. Factory validation failures expose gooptions.ValidationError through errors.As.

func WithShutdownTimeout

func WithShutdownTimeout(timeout time.Duration) RunOption

WithShutdownTimeout bounds Run's shutdown wait, starting when shutdown begins. The default is 30 seconds; an override must be positive. An explicit Shutdown deadline may shorten this budget. Timeout stops transport but does not imply hosted cleanup has settled; later Shutdown calls can observe its retained result.

type RuntimeIdentity

type RuntimeIdentity struct {
	Name       string
	Version    string
	InstanceID string
}

RuntimeIdentity is optional host-supplied handshake metadata. Wire does not derive it from the runtime implementation or process environment.

type Server

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

Server hosts Wire through Run or a caller-created listener passed to Serve. It borrows the runtime passed to New and never closes it. Serving is single-use.

func New

func New(runtime api.Runtime, options ...Option) (*Server, error)

New adapts a caller-configured runtime without taking ownership or creating a listener. Limits default to DefaultLimits. Option failures are joined after all non-nil options run, before server construction.

func (*Server) Run

func (s *Server) Run(ctx context.Context, address string, options ...RunOption) error

Run opens a TCP listener at address and manages serving and shutdown. No default endpoint is supplied. Cancellation after startup returns nil if cleanup succeeds. Shutdown defaults to a 30-second budget, independent of ctx. A timeout matches context.DeadlineExceeded and leaves committed hosted cleanup observable through Shutdown. Option failures are joined before startup reservation or listening. Run never closes the borrowed runtime.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, listener net.Listener) error

Serve accepts a caller-created listener, including Unix sockets and custom transports. Once accepted, gRPC closes it when serving returns. Cancellation initiates shutdown; callers use Shutdown to wait for retained cleanup results. Serve has no default shutdown timeout. Rejected starts leave the listener untouched.

func (*Server) Shutdown

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

Shutdown commits logical cleanup once and waits with ctx. The earliest supplied deadline forces transport shutdown; later calls cannot extend it or an active Run's budget. Transport stopping does not finish hosted cleanup. Concurrent and subsequent callers observe the same retained settlement result.

Directories

Path Synopsis
internal
core
Package core owns Wire's logical resource lifetimes and protocol-neutral operations.
Package core owns Wire's logical resource lifetimes and protocol-neutral operations.
grpcserver
Package grpcserver translates Wire RPCs into core operations and sanitized protocol responses.
Package grpcserver translates Wire RPCs into core operations and sanitized protocol responses.
lifecycle
Package lifecycle coordinates retained teardown results and independently cancellable waiters.
Package lifecycle coordinates retained teardown results and independently cancellable waiters.
panicboundary
Package panicboundary contains panics raised by externally supplied implementations at an explicit call boundary.
Package panicboundary contains panics raised by externally supplied implementations at an explicit call boundary.

Jump to

Keyboard shortcuts

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