manager

package
v0.0.0-...-a7cdbd9 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EpollManager

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

EpollManager 基于 linux epoll 实现连接管理

func New

func New() (*EpollManager, error)

New 初始化连接管理池

func (*EpollManager) Add

func (e *EpollManager) Add(conn connect.ConnI) error

Add 添加连接到连接池

func (*EpollManager) Conn

func (e *EpollManager) Conn(connID int) (connect.ConnI, error)

Conn 根据连接的id从连接池里获取连接

func (*EpollManager) Remove

func (e *EpollManager) Remove(conn connect.ConnI) error

Remove 移除连接

func (*EpollManager) Size

func (e *EpollManager) Size() int

Size 获取连接数量

func (*EpollManager) Vacuum

func (e *EpollManager) Vacuum()

Vacuum 清空连接池

func (*EpollManager) Wait

func (e *EpollManager) Wait(maxEvent int) ([]net.Conn, error)

Wait 等待 maxEvent 为每次最多读取的事件数量,默认配置 100,最大1000

type ManagerI

type ManagerI interface {

	// Add 添加链接
	Add(conn connect.ConnI) error

	// Remove 删除连接
	Remove(conn connect.ConnI) error

	// Conn 根据ConnID获取Tcp连接
	Conn(connID int) (connect.ConnI, error)

	// Size 获取当前连接数
	Size() int

	// Vacuum 清空连接
	Vacuum()
}

ManagerI TCP 连接管理,添加、删除、通过以恶搞连接ID获得连接对象,当前连接数、清空全部连接等方法

Jump to

Keyboard shortcuts

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