Documentation
¶
Overview ¶
Package drpc provides the drpc server for go-orb.
Package drpc provides a drpc mux that handles orb middleware.
Index ¶
- Constants
- Variables
- func New(acfg any, logger log.Logger, reg registry.Type) (orbserver.Entrypoint, error)
- func Provide(sections []string, configs types.ConfigData, logger log.Logger, ...) (orbserver.Entrypoint, error)
- func WithAddress(address string) server.Option
- func WithHandlers(h ...server.RegistrationFunc) server.Option
- func WithListener(l net.Listener) server.Option
- func WithLogLevel(level string) server.Option
- func WithLogPlugin(plugin string) server.Option
- func WithMaxConcurrentStreams(n int) server.Option
- func WithMiddleware(m string) server.Option
- func WithName(name string) server.Option
- type Config
- type Mux
- type Server
- func (s *Server) AddEndpoint(name string)
- func (s *Server) Address() string
- func (s *Server) Enabled() bool
- func (s *Server) EntrypointID() string
- func (s *Server) Name() string
- func (s *Server) Register(register orbserver.RegistrationFunc)
- func (s *Server) Router() *Mux
- func (s *Server) Start() error
- func (s *Server) Stop(_ context.Context) error
- func (s *Server) String() string
- func (s *Server) Transport() string
- func (s *Server) Type() string
Constants ¶
const ( // DefaultAddress to use for new dRPC servers. DefaultAddress = ":0" // DefaultMaxConcurrentStreams for dRPC. DefaultMaxConcurrentStreams = 256 )
const Plugin = "drpc"
Plugin is the plugin name.
Variables ¶
var ( // ErrInvalidConfigType is returned when you provided an invalid config type. ErrInvalidConfigType = errors.New("drpc server: invalid config type provided, not of type drpc.Config") )
Errors.
Functions ¶
func Provide ¶
func Provide( sections []string, configs types.ConfigData, logger log.Logger, reg registry.Type, opts ...orbserver.Option, ) (orbserver.Entrypoint, error)
Provide creates a new entrypoint for a single address. You can create multiple entrypoints for multiple addresses and ports.
func WithAddress ¶
WithAddress specifies the address to listen on. If you want to listen on all interfaces use the format "[::]:8080" If you want to listen on a specific interface/address use the full IP.
func WithHandlers ¶
func WithHandlers(h ...server.RegistrationFunc) server.Option
WithHandlers adds custom handlers.
func WithListener ¶
WithListener sets the entrypoints listener. This overwrites `Address`.
func WithLogLevel ¶
WithLogLevel changes the log level from the inherited logger.
func WithLogPlugin ¶
WithLogPlugin changes the log level from the inherited logger.
func WithMaxConcurrentStreams ¶
WithMaxConcurrentStreams sets the worker pool size.
func WithMiddleware ¶
WithMiddleware adds a pre-registered middleware.
Types ¶
type Config ¶
type Config struct { server.EntrypointConfig `yaml:",inline"` // Listener can be used to provide your own Listener, when in use `Address` is obsolete. Listener net.Listener `json:"-" yaml:"-"` // Address to listen on. // If no port is provided, a random port will be selected. To listen on a // specific interface, but with a random port, you can use '<IP>:0'. Address string `json:"address" yaml:"address"` // MaxConcurrentStreams is the worker pool size. MaxConcurrentStreams int `json:"maxConcurrentStreams" yaml:"maxConcurrentStreams"` // Middlewares is a list of middleware to use. Middlewares []server.MiddlewareConfig `json:"middlewares" yaml:"middlewares"` // Handlers is a list of pre-registered handlers. Handlers []string `json:"handlers" yaml:"handlers"` // Logger allows you to dynamically change the log level and plugin for a // specific entrypoint. Logger log.Config `json:"logger" yaml:"logger"` }
Config provides options to the entrypoint.
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux is an implementation of Handler to serve drpc connections to the appropriate Receivers registered by Descriptions.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the drpc Server for go-orb.
func (*Server) AddEndpoint ¶
AddEndpoint add's an endpoint to the internal list. This is used by the Register() callback function.
func (*Server) Address ¶
Address returns the address the entrypoint is listening on, for example: [::]:8381.
func (*Server) EntrypointID ¶
EntrypointID returns the id (uuid) of this entrypoint in the registry.
func (*Server) Register ¶
func (s *Server) Register(register orbserver.RegistrationFunc)
Register executes a registration function on the entrypoint.