netutil

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

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

Go to latest
Published: Sep 30, 2018 License: MIT Imports: 10 Imported by: 0

README

netutil

plug'n play net.Listener wrapper / multiplexer

GoDoc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrByteHeaderNotFound          = errors.New("byte header not found")
	ErrByteHeaderAlreadyRegistered = errors.New("byte header already registered")
)
View Source
var (
	ErrConnectionClosed = errors.New("connection closed")
)
View Source
var (
	ErrWrongHandlerReached = errors.New("wrong handler reached")
)

Functions

This section is empty.

Types

type BytesRWHandlerFunc

type BytesRWHandlerFunc func(interface{}) (interface{}, error)

type Matcher

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

func CreateEmptyMatcher

func CreateEmptyMatcher() *Matcher

func (*Matcher) Invoke

func (m *Matcher) Invoke(k interface{}, r io.Reader, w io.Writer, c net.Conn) error

func (*Matcher) Match

func (m *Matcher) Match(k interface{}) (RWHandler, error)

func (*Matcher) Register

func (m *Matcher) Register(k interface{}, h RWHandler) error

func (*Matcher) RegisterByte

func (m *Matcher) RegisterByte(b byte, h RWHandler) error

func (*Matcher) RegisterBytes

func (m *Matcher) RegisterBytes(bytes []byte, h RWHandler) error

func (*Matcher) RegisterString

func (m *Matcher) RegisterString(s string, h RWHandler) error

type RWHandler

type RWHandler func(io.Reader, io.Writer, net.Conn) error

func BytesRWHandler

func BytesRWHandler(handle BytesRWHandlerFunc, i interface{}, c codec.Handle) RWHandler

func GoNetRPCRWHandler

func GoNetRPCRWHandler(setupFunc func(*rpc.Server)) RWHandler

func ServeMuxRWHandler

func ServeMuxRWHandler(setupFunc func(*http.ServeMux), addr net.Addr) RWHandler

type Socket

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

func Bind

func Bind(li net.Listener) *Socket

func (*Socket) Accept

func (s *Socket) Accept(wg *sync.WaitGroup, lg *log.Logger, t time.Duration) error

func (*Socket) Matcher

func (s *Socket) Matcher() *Matcher

func (*Socket) Register

func (s *Socket) Register(bytes []byte, h RWHandler) error

Jump to

Keyboard shortcuts

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