conn

package module
v0.0.0-...-6a4d443 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2018 License: MIT Imports: 10 Imported by: 0

README

Golang Conn

使用netpoll将连接处理改为事件驱动,并建立goroutine协程池化,使协程数<连接数,具体降到多少根据数据传输的频次评估,尤其对于高连接数、低频数据传输的场景,可以大幅降低协程数与连接数的比例。

  • 事件驱动模型

conn

参考内容

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServerClosed = errors.New("server: server closed")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Conn net.Conn

	WriteHandler ConnWriteHandler
	// contains filtered or unexported fields
}

func NewClient

func NewClient(addr string) (*Client, error)

func (*Client) Dial

func (c *Client) Dial() error

func (*Client) Send

func (c *Client) Send(p []byte) (n int, err error)

type Conn

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

type ConnHandler

type ConnHandler func(conn *Conn) error

type ConnReadHandler

type ConnReadHandler func(conn net.Conn) error

type ConnWriteHandler

type ConnWriteHandler func(conn net.Conn, p []byte) (int, error)

type Option

type Option func(*Options)

func ReaderPoolSize

func ReaderPoolSize(size int64) Option

func WriterPoolSize

func WriterPoolSize(size int64) Option

type Options

type Options struct {
	ReaderPoolSize int64

	WriterPoolSize int64
}

type Server

type Server struct {
	ConnHandler  ConnHandler
	ReadHandler  ConnReadHandler
	WriteHandler ConnWriteHandler
	// contains filtered or unexported fields
}

func NewServer

func NewServer(opts ...Option) (*Server, error)

func (*Server) Close

func (srv *Server) Close() error

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe(network, address string) error

Directories

Path Synopsis
pkg
gopool
Package gopool contains tools for goroutine reuse.
Package gopool contains tools for goroutine reuse.
log

Jump to

Keyboard shortcuts

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