mux

package module
v0.0.0-...-8c2c289 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2015 License: MIT Imports: 10 Imported by: 3

README

Mux Build Status

Mux is a library for multiplexing streams.

Bitdeli Badge

Documentation

Index

Constants

View Source
const (
	// ErrType for errors
	ErrType uint8 = iota
	// LogType for logs
	LogType
	// SignalType for signals
	SignalType
)

Variables

View Source
var (
	// ErrInvalidTimeout defines an error for an invalid Config Timeout value
	ErrInvalidTimeout = errors.New("Invalid Config Timeout")
	// ErrInvalidLager defines an error for an invalid Config Lager value
	ErrInvalidLager = errors.New("Invalid Lager")
)

Functions

This section is empty.

Types

type Buffer

type Buffer interface {
	Write(b []byte) (int, error)
	Bytes() []byte
	Len() int
	Reset()
}

Buffer is an interface for buffering

type BufferDecoder

type BufferDecoder interface {
	Buffer
	Decoder
}

BufferDecoder is a Buffer and Decoder

type BufferEncoder

type BufferEncoder interface {
	Buffer
	Encoder
}

BufferEncoder is a Buffer and Encoder

type Client

type Client interface {
	Conn
	Wait() error
}

Client is a client uses Conn

func NewClient

func NewClient(conn Conn) (Client, error)

NewClient returns a new GobClient

type Config

type Config struct {
	// Timeout for receiving frames
	Timeout time.Duration

	// Lager is used to control the log destination
	Lager lager.Lager
}

Config configures a Server or Client

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig creates config with default settings

func (*Config) Verify

func (c *Config) Verify() error

Verify validates the config

type Conn

type Conn interface {
	// Receive registers a receiver to receive t
	Receive(t uint8, r Receiver)
	// Send encodes a frame on conn using t and e
	Send(t uint8, e interface{}) error
	// Recv listens for frames and sends them to a receiver
	Recv()
	// Pool returns the pool used by the Conn
	Pool() Pool
	// Shutdown closes the gob connection
	Shutdown()
	// IsShutdown provides a way to listen for this connection to shutdown
	IsShutdown() chan struct{}
}

Conn defines a mux connection

func NewConn

func NewConn(netConn net.Conn, pool Pool, config *Config) (Conn, error)

NewConn creates a new NetConn using the specified conn and config

type Decoder

type Decoder interface {
	Decode(v interface{}) error
}

Decoder decodes

type Encoder

type Encoder interface {
	Encode(v interface{}) error
}

Encoder encodes

type Frame

type Frame struct {
	Type uint8
	Data []byte
}

Frame represents transport

type Pool

type Pool interface {
	NewBufferEncoder() BufferEncoder
	NewBufferDecoder() BufferDecoder
	NewEncoder(w io.Writer) Encoder
	NewDecoder(r io.Reader) Decoder
	NewReceiver(ch interface{}) Receiver
	NewClient(conn net.Conn, config *Config) (Client, error)
	NewServer(conn net.Conn, config *Config) (Server, error)
}

Pool is an interface for interacting with encoding implementations

type Receiver

type Receiver interface {
	Receive(b []byte) error
	Close() error
}

Receiver defines an interface for receiving

func NewReceiver

func NewReceiver(ch interface{}, pool Pool) Receiver

NewReceiver creates a new Receiver.

type Server

type Server interface {
	Conn
	Done(err error)
}

Server is a server that uses Conn

func NewServer

func NewServer(conn Conn) (Server, error)

NewServer creates a new GobServer

type SignalReceiver

type SignalReceiver struct {
	// contains filtered or unexported fields
}

SignalReceiver receives signals

func NewSignalReceiver

func NewSignalReceiver(ch chan os.Signal, pool Pool) SignalReceiver

NewSignalReceiver creates a new signal receiver

func (SignalReceiver) Close

func (r SignalReceiver) Close() error

Close and cleans up SignalReceiver

func (SignalReceiver) Receive

func (r SignalReceiver) Receive(b []byte) error

Receive decodes bytes into signal and puts it on ch

type StringReceiver

type StringReceiver struct {
	// contains filtered or unexported fields
}

StringReceiver receives strings

func NewStringReceiver

func NewStringReceiver(ch chan string, pool Pool) StringReceiver

NewStringReceiver returns a StringReceiver

func (StringReceiver) Close

func (r StringReceiver) Close() error

Close and cleans up StringReceiver

func (StringReceiver) Receive

func (r StringReceiver) Receive(b []byte) error

Receive decodes bytes into string and puts it on ch

type ValueReceiver

type ValueReceiver struct {
	// contains filtered or unexported fields
}

ValueReceiver uses reflection to send and receive values

func (*ValueReceiver) Close

func (r *ValueReceiver) Close() error

func (*ValueReceiver) Receive

func (r *ValueReceiver) Receive(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL