Documentation
¶
Index ¶
- Constants
- Variables
- func IsSinkClosed(err error) bool
- func NewSinkWriter(sink luigi.Sink) io.WriteCloser
- func NewSourceReader(src luigi.Source) io.Reader
- type CallError
- type CallType
- type Endpoint
- type Handler
- type HandlerMux
- type HandlerWrapper
- type Method
- type NamedHandler
- type Packer
- type Request
- type Server
- type Stream
Constants ¶
View Source
const ChunkSize = 65536
Variables ¶
View Source
var ( ErrStreamNotReadable = errors.New("muxrpc: this stream can not be read from") ErrStreamNotWritable = errors.New("muxrpc: this stream can not be written to") ErrStreamNotClosable = errors.New("muxrpc: this stream can not be closed") )
View Source
var ErrSessionTerminated = errors.New("muxrpc: session terminated")
Functions ¶
func IsSinkClosed ¶ added in v1.3.0
IsSinkClosed should be moved to luigi to gether with the error
func NewSinkWriter ¶ added in v1.1.0
func NewSinkWriter(sink luigi.Sink) io.WriteCloser
Types ¶
type CallError ¶
type CallError struct { Name string `json:"name"` Message string `json:"message"` Stack string `json:"stack"` }
CallError is returned when a call fails
type Endpoint ¶
type Endpoint interface { // The different call types: Async(ctx context.Context, tipe interface{}, method Method, args ...interface{}) (interface{}, error) Source(ctx context.Context, tipe interface{}, method Method, args ...interface{}) (luigi.Source, error) Sink(ctx context.Context, method Method, args ...interface{}) (luigi.Sink, error) Duplex(ctx context.Context, tipe interface{}, method Method, args ...interface{}) (luigi.Source, luigi.Sink, error) // Do allows general calls Do(ctx context.Context, req *Request) error // Terminate wraps up the RPC session Terminate() error // Remote returns the network address of the remote Remote() net.Addr }
Endpoint allows calling functions on the RPC peer.
func HandleWithLogger ¶ added in v1.5.0
HandleWithLogger same as Handle but let's you overwrite the stderr logger
type Handler ¶
type Handler interface { HandleCall(ctx context.Context, req *Request, edp Endpoint) HandleConnect(ctx context.Context, edp Endpoint) }
Handler allows handling connections. When we are being called, HandleCall is called. When a connection is established, HandleConnect is called. TODO: let HandleCall return an error
func ApplyHandlerWrappers ¶ added in v1.3.0
func ApplyHandlerWrappers(h Handler, hws ...HandlerWrapper) Handler
type HandlerMux ¶
type HandlerMux struct {
// contains filtered or unexported fields
}
func (*HandlerMux) HandleCall ¶
func (hm *HandlerMux) HandleCall(ctx context.Context, req *Request, edp Endpoint)
func (*HandlerMux) HandleConnect ¶
func (hm *HandlerMux) HandleConnect(ctx context.Context, edp Endpoint)
func (*HandlerMux) Register ¶
func (hm *HandlerMux) Register(m Method, h Handler)
func (*HandlerMux) RegisterAll ¶ added in v1.5.0
func (hm *HandlerMux) RegisterAll(handlers ...NamedHandler)
type HandlerWrapper ¶ added in v1.3.0
type NamedHandler ¶ added in v1.5.0
type Packer ¶
Packer is a duplex stream that sends and receives *codec.Packet values. Usually wraps a network connection or stdio.
func NewPacker ¶
func NewPacker(rwc io.ReadWriteCloser) Packer
NewPacker takes an io.ReadWriteCloser and returns a Packer.
type Request ¶
type Request struct { // Stream allows sending and receiving packets Stream Stream `json:"-"` // Method is the name of the called function Method Method `json:"name"` // Args contains the call arguments RawArgs json.RawMessage `json:"args"` // Type is the type of the call, i.e. async, sink, source or duplex Type CallType `json:"type"` // contains filtered or unexported fields }
Request assembles the state of an RPC call
func (*Request) CloseWithError ¶ added in v1.3.0
type Stream ¶
type Stream interface { luigi.Source luigi.Sink luigi.ErrorCloser // WithType tells the stream in what type JSON data should be unmarshalled into WithType(tipe interface{}) // WithReq tells the stream what request number should be used for sent messages WithReq(req int32) }
Stream is a muxrpc stream for the general duplex case.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
muxgen
muxgen generates code to easily call functions on the endpoint type myEndpoint struct { // ...
|
muxgen generates code to easily call functions on the endpoint type myEndpoint struct { // ... |
Package codec implements readers and writers for https://github.com/dominictarr/packet-stream-codec Packet structure: ( [flags (1byte), length (4 bytes, UInt32BE), req (4 bytes, Int32BE)] # Header [body (length bytes)] ) * [zeros (9 bytes)] Flags: [ignored (4 bits), stream (1 bit), end/err (1 bit), type (2 bits)] type = {0 => Buffer, 1 => String, 2 => JSON} # PacketType
|
Package codec implements readers and writers for https://github.com/dominictarr/packet-stream-codec Packet structure: ( [flags (1byte), length (4 bytes, UInt32BE), req (4 bytes, Int32BE)] # Header [body (length bytes)] ) * [zeros (9 bytes)] Flags: [ignored (4 bits), stream (1 bit), end/err (1 bit), type (2 bits)] type = {0 => Buffer, 1 => String, 2 => JSON} # PacketType |
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
Click to show internal directories.
Click to hide internal directories.