Documentation
¶
Overview ¶
Package wsproto serves services over ws-proto (protobuf RPC over WebSocket) as a managed public api: gRPC services, with the same register function as Service.GRPC so one implementation serves both, or handlers generated for ws-proto itself. Every call is traced and a panicking one ends with codes.Internal, like on the gRPC server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Serve ¶
func Serve[St any, R Register]( svc *backplane.Service[St], prefix string, origins api.Origins, register R, opts ...api.WSProtoOption, )
Serve mounts a ws-proto endpoint at prefix on a public port of svc and announces it with the registered services' descriptors. origins is the browser origin policy: the zero value admits same-origin browsers and non-browser clients only.
api.Middleware wraps the endpoint once per connection: the connection's context is the one it passes on (see api.Middleware). api.CallMiddleware wraps every call; api.Interceptors and api.StreamInterceptors wrap the calls of gRPC-registered services only. api.Keepalive tunes pings.
Types ¶
type Register ¶ added in v0.6.46
type Register interface {
func(grpc.ServiceRegistrar) | func(*wsrpc.Server)
}
Register is what Serve registers the endpoint's services with: the register function of Service.GRPC, or one that registers ws-proto generated handlers (Register<Service>Handler) on the endpoint's server.