yamuxer

package module
v0.0.0-...-af88920 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2015 License: Apache-2.0 Imports: 8 Imported by: 1

README

yamuxer

Yamuxer is an abstraction over Yamux which dispatches streams to handlers based on type

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Listener   *net.TCPListener
	TLSConfig  *tls.Config
	Dispatcher Dispatcher
	Deadline   time.Duration
	LogOutput  io.Writer
}

Config is used to create a new yamuxer.

type Dispatcher

type Dispatcher interface {

	// Register adds a Handler for the given type.
	Register(StreamType, Handler)

	// RegisterFunc adds a HandlerFunc for the given type.
	RegisterFunc(StreamType, HandlerFunc)

	// Dispatch reads the first byte and passes the connection to the handler
	// for the given type.
	Dispatch(grim.GrimReaper, net.Conn)
}

Dispatcher processes stream connections and hands them off to the registered handler.

func NewDispatcher

func NewDispatcher(l log.Logger, unknownHandler Handler) Dispatcher

NewDispatcher creates a Dispatcher implementation which also allows for the optional handling of unknown streams. If the unknown handler is nil, the streams will be closed immediately.

type Handler

type Handler interface {
	Handle(context.Context, net.Conn)
}

Handler handles incoming stream connections for a stream type.

type HandlerFunc

type HandlerFunc func(context.Context, net.Conn)

HandlerFunc handles incoming stream connections.

type StreamType

type StreamType byte

StreamType is the stream enum. There can only be one handler per type. 0x00 is a reserved StreamType.

var UnknownStreamType StreamType = 0x00

UnknownStreamType is a cautionary type as it covered the nil byte.

type Yamuxer

type Yamuxer interface {
	Start()
	Stop()
}

Yamuxer is a simple interface which starts listening for connections on Start and waits for all connections to be closed on Stop.

func New

func New(context context.Context, c *Config) Yamuxer

New creates an implementation of the Yamuxer interface using the given context and config.

Directories

Path Synopsis
Godeps
_workspace/src/github.com/mattn/go-isatty
Package isatty implements interface to isatty
Package isatty implements interface to isatty
_workspace/src/github.com/mgutz/ansi
Package ansi is a small, fast library to create ANSI colored strings and codes.
Package ansi is a small, fast library to create ANSI colored strings and codes.
_workspace/src/golang.org/x/net/context
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.

Jump to

Keyboard shortcuts

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