gnetws

package module
v1.1.7 Latest Latest
Warning

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

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

README

gnetws

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Nonblocking decides what to do when submitting a new task to a full worker pool: waiting for a available worker
	// or returning nil directly.
	Nonblocking = true

	// ExpiryDuration is the interval time to clean up those expired workers.
	ExpiryDuration = 10 * time.Second

	// DefaultAntsPoolSize sets up the capacity of worker pool, 1024 * cpu.
	DefaultAntsPoolSize = (1 << 10) * runtime.NumCPU() * 2
)
View Source
var GoroutinePool = func() func() Pool {
	var pool Pool
	once := sync.Once{}
	options := ants.Options{
		Nonblocking:    Nonblocking,
		ExpiryDuration: ExpiryDuration,
	}

	return func() Pool {
		once.Do(func() {
			pool, _ = ants.NewPool(
				DefaultAntsPoolSize, ants.WithOptions(options),
			)
		})
		return pool
	}
}()

Functions

This section is empty.

Types

type Broadcast added in v1.1.1

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

func NewBroadcast added in v1.1.1

func NewBroadcast(wrapper Packing, docodec Serialize) *Broadcast

func (*Broadcast) RegisterConn added in v1.1.1

func (self *Broadcast) RegisterConn(c gnet.Conn)

func (*Broadcast) SendMessage added in v1.1.1

func (self *Broadcast) SendMessage(x interface{}) (err error)

func (*Broadcast) WriteOffConn added in v1.1.1

func (self *Broadcast) WriteOffConn(c gnet.Conn)

type Buffer added in v1.1.1

type Buffer struct {
	sync.Mutex
	bytes.Buffer
}

func (*Buffer) Read added in v1.1.1

func (self *Buffer) Read(p []byte) (int, error)

func (*Buffer) Write added in v1.1.1

func (self *Buffer) Write(b []byte) (int, error)

type Decode added in v1.1.2

type Decode interface {
	Decode(x interface{}) (err error)
}

type Encode added in v1.1.2

type Encode interface {
	Encode(x interface{}) (err error)
}

type Packing added in v1.1.1

type Packing interface {
	io.Writer
	Flush() error
	SubPackage() (p []byte)
}

type Pool

type Pool = *ants.Pool

type PoolWithFunc

type PoolWithFunc = *ants.PoolWithFunc

type Serialize added in v1.1.2

type Serialize interface {
	NewEnCodec(w io.Writer) Encode
	NewDeCodec(r io.Reader) Decode
}

Serialize 序列化器

type WebSocketWrapper added in v1.1.1

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

func NewWebSocketWrapper added in v1.1.1

func NewWebSocketWrapper() *WebSocketWrapper

func (*WebSocketWrapper) Flush added in v1.1.1

func (self *WebSocketWrapper) Flush() error

func (*WebSocketWrapper) SubPackage added in v1.1.1

func (self *WebSocketWrapper) SubPackage() []byte

func (*WebSocketWrapper) Write added in v1.1.1

func (self *WebSocketWrapper) Write(p []byte) (int, error)

Directories

Path Synopsis
Package cron implements a cron spec parser and job runner.
Package cron implements a cron spec parser and job runner.
example-app
net-protocol

Jump to

Keyboard shortcuts

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