lwnet

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

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

Go to latest
Published: Dec 8, 2019 License: Apache-2.0 Imports: 11 Imported by: 1

README

lwnet-go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(eventHandler EventHandler, addr string, opts ...Option) error

Types

type Connection

type Connection interface {
	Write(data []byte)
	IsConnected() bool
	RemoteAddr() net.Addr
	Close()
	GetSysFd() int
	SetContext(ctx interface{})
	GetContext() interface{}
}

type EventHandler

type EventHandler interface {
	OnNewConnect(c Connection)
	OnNewRead(c Connection, readBuffer *ringbuffer.RingBuffer)
	OnClose(c Connection)
}

type Option

type Option func(opts *Options)

func WithAcceptCoroutineNum

func WithAcceptCoroutineNum(acceptCoroutineNum int) Option

func WithEventCoroutineNum

func WithEventCoroutineNum(eventCoroutineNum int) Option

func WithReusePort

func WithReusePort(reusePort bool) Option

func WithRingBufSize

func WithRingBufSize(ringBufSize int) Option

type Options

type Options struct {
	AcceptCoroutineNum int
	EventCoroutineNum  int

	RingBufSize int

	// ReusePort indicates whether to set up the SO_REUSEPORT option.
	ReusePort bool
}

type Poller

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

func Create

func Create() (*Poller, error)

func (*Poller) AddRead

func (ep *Poller) AddRead(fd int) error

func (*Poller) AddWrite

func (ep *Poller) AddWrite(fd int) error

func (*Poller) Delete

func (ep *Poller) Delete(fd int) error

func (*Poller) ModRead

func (ep *Poller) ModRead(fd int) error

func (*Poller) ModReadWrite

func (ep *Poller) ModReadWrite(fd int) error

func (*Poller) Poll

func (ep *Poller) Poll(handler func(fd int, event int32))

func (*Poller) Trigger

func (ep *Poller) Trigger(job internal.Job) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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