Documentation
¶
Overview ¶
Package typemux offers an improved muxrpc.HandlerMux (think HTTP router). compared to the first draft, this one offers specialed handler functions for the different call types (async, source, sink) to reduce boilerplate in handlers.
Index ¶
- type AsyncFunc
- type AsyncHandler
- type DuplexFunc
- type DuplexHandler
- type HandlerMux
- func (hm *HandlerMux) HandleCall(ctx context.Context, req *muxrpc.Request)
- func (hm *HandlerMux) HandleConnect(ctx context.Context, edp muxrpc.Endpoint)
- func (hm *HandlerMux) Handled(m muxrpc.Method) bool
- func (hm *HandlerMux) RegisterAsync(m muxrpc.Method, h AsyncHandler)
- func (hm *HandlerMux) RegisterDuplex(m muxrpc.Method, h DuplexHandler)
- func (hm *HandlerMux) RegisterSink(m muxrpc.Method, h SinkHandler)
- func (hm *HandlerMux) RegisterSource(m muxrpc.Method, h SourceHandler)
- type SinkFunc
- type SinkHandler
- type SourceFunc
- type SourceHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncHandler ¶
type DuplexFunc ¶
DuplexFunc is a utility to fulfill DuplexHandler just as a function, not a type with the named method
func (DuplexFunc) HandleDuplex ¶
func (sf DuplexFunc) HandleDuplex(ctx context.Context, r *muxrpc.Request, src *muxrpc.ByteSource, snk *muxrpc.ByteSink) error
HandleDuplex implements the duplex handler for the function
type DuplexHandler ¶
type DuplexHandler interface {
HandleDuplex(context.Context, *muxrpc.Request, *muxrpc.ByteSource, *muxrpc.ByteSink) error
}
DuplexHandler initiates a 'duplex' call. The handler receives data from the peer through the passed source
type HandlerMux ¶
type HandlerMux struct {
// contains filtered or unexported fields
}
func New ¶
func New(log log.Logger) HandlerMux
func (*HandlerMux) HandleCall ¶
func (hm *HandlerMux) HandleCall(ctx context.Context, req *muxrpc.Request)
func (*HandlerMux) HandleConnect ¶
func (hm *HandlerMux) HandleConnect(ctx context.Context, edp muxrpc.Endpoint)
func (*HandlerMux) Handled ¶
func (hm *HandlerMux) Handled(m muxrpc.Method) bool
func (*HandlerMux) RegisterAsync ¶
func (hm *HandlerMux) RegisterAsync(m muxrpc.Method, h AsyncHandler)
RegisterAsync registers a 'async' call for name method
func (*HandlerMux) RegisterDuplex ¶
func (hm *HandlerMux) RegisterDuplex(m muxrpc.Method, h DuplexHandler)
RegisterDuplex registers a 'sink' call for name method
func (*HandlerMux) RegisterSink ¶
func (hm *HandlerMux) RegisterSink(m muxrpc.Method, h SinkHandler)
RegisterSink registers a 'sink' call for name method
func (*HandlerMux) RegisterSource ¶
func (hm *HandlerMux) RegisterSource(m muxrpc.Method, h SourceHandler)
RegisterSource registers a 'source' call for name method
type SinkFunc ¶
SinkFunc is a utility to fulfill SinkHandler just as a function, not a type with the named method
type SinkHandler ¶
type SinkHandler interface {
HandleSink(context.Context, *muxrpc.Request, *muxrpc.ByteSource) error
}
SinkHandler initiates a 'sink' call. The handler receives data from the peer through the passed source
type SourceFunc ¶
func (SourceFunc) HandleSource ¶
func (sf SourceFunc) HandleSource(ctx context.Context, r *muxrpc.Request, src *muxrpc.ByteSink) error
type SourceHandler ¶
type SourceHandler interface {
HandleSource(context.Context, *muxrpc.Request, *muxrpc.ByteSink) error
}
SourceHandler initiates a 'source' call, so the handler is supposed to send a stream of stuff to the peer.