Documentation
¶
Overview ¶
Package memory provides the memory RPC server for go-orb.
Package memory provides a memory RPC mux that handles orb middleware.
Index ¶
- Constants
- func CreateClientServerPair(ctx context.Context, endpoint string) (*Stream, *Stream)
- func New(serviceName string, serviceVersion string, epName string, acfg any, ...) (orbserver.Entrypoint, error)
- func Provide(serviceName string, serviceVersion string, epName string, ...) (orbserver.Entrypoint, error)
- func WithHandlers(h ...server.RegistrationFunc) server.Option
- func WithLogLevel(level string) server.Option
- func WithLogPlugin(plugin string) server.Option
- func WithMaxConcurrentStreams(n int) server.Option
- type Config
- type Mux
- type Server
- func (s *Server) AddEndpoint(name string)
- func (s *Server) AddHandler(handler orbserver.RegistrationFunc)
- func (s *Server) Address() string
- func (s *Server) Enabled() bool
- func (s *Server) Name() string
- func (s *Server) Network() string
- func (s *Server) Register(register orbserver.RegistrationFunc)
- func (s *Server) Request(ctx context.Context, infos client.RequestInfos, req any, result any, ...) error
- func (s *Server) Router() *Mux
- func (s *Server) Start(ctx context.Context) error
- func (s *Server) Stop(_ context.Context) error
- func (s *Server) Stream(ctx context.Context, infos client.RequestInfos, opts *client.CallOptions) (client.StreamIface[any, any], error)
- func (s *Server) String() string
- func (s *Server) Transport() string
- func (s *Server) Type() string
- type Stream
- func (s *Stream) Close() error
- func (s *Stream) CloseSend() error
- func (s *Stream) Context() context.Context
- func (s *Stream) MsgRecv(msg drpc.Message, _ drpc.Encoding) error
- func (s *Stream) MsgSend(msg drpc.Message, _ drpc.Encoding) error
- func (s *Stream) Recv(msg any) error
- func (s *Stream) Send(msg any) error
Constants ¶
const (
// DefaultMaxConcurrentStreams for memory.
DefaultMaxConcurrentStreams = 256
)
const Name = "memory"
Name is the plugin name.
Variables ¶
This section is empty.
Functions ¶
func CreateClientServerPair ¶
CreateClientServerPair creates a pair of connected streams for client and server.
func New ¶
func New( serviceName string, serviceVersion string, epName string, acfg any, logger log.Logger, reg registry.Type, ) (orbserver.Entrypoint, error)
New creates a memory Server from a Config struct.
func Provide ¶
func Provide( serviceName string, serviceVersion string, epName string, configs map[string]any, 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 WithHandlers ¶
func WithHandlers(h ...server.RegistrationFunc) server.Option
WithHandlers adds custom handlers.
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.
Types ¶
type Config ¶
type Config struct {
server.EntrypointConfig `yaml:",inline"`
// MaxConcurrentStreams is the worker pool size.
MaxConcurrentStreams int `json:"maxConcurrentStreams" yaml:"maxConcurrentStreams"`
// 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 memory Server for go-orb.
func (*Server) AddEndpoint ¶
AddEndpoint adds an endpoint to the internal list. This is used by the Register() callback function.
func (*Server) AddHandler ¶
func (s *Server) AddHandler(handler orbserver.RegistrationFunc)
AddHandler adds a handler for later registration.
func (*Server) Address ¶
Address returns an empty string as memory server doesn't have a network address.
func (*Server) Register ¶
func (s *Server) Register(register orbserver.RegistrationFunc)
Register executes a registration function on the entrypoint.
func (*Server) Request ¶
func (s *Server) Request(ctx context.Context, infos client.RequestInfos, req any, result any, opts *client.CallOptions) error
Request implements the client.MemoryServer interface.
func (*Server) Stream ¶
func (s *Server) Stream( ctx context.Context, infos client.RequestInfos, opts *client.CallOptions, ) (client.StreamIface[any, any], error)
Stream creates a new bidirectional stream for memory-based RPC communication.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream implements the client.StreamIface and the drpc.Stream interface for memory-based streaming.
func (*Stream) CloseSend ¶
CloseSend closes the send side of the stream but keeps the receive side open.