internal

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TCP       = "tcp"
	WEBSOCKET = "ws"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer[T any] struct {
	// contains filtered or unexported fields
}

Buffer represents a buffer of any object

func NewBuffer

func NewBuffer[T any](size int) *Buffer[T]

NewBuffer returns a new buffer with the given size

func (*Buffer[T]) Empty

func (buffer *Buffer[T]) Empty() bool

Empty returns true if the buffer is empty

func (*Buffer[T]) Length

func (buffer *Buffer[T]) Length() int

Length returns the length of buffer

func (*Buffer[T]) Offer

func (buffer *Buffer[T]) Offer(items ...T)

Offer push the active fd to the queue, it will be deposed when buffer is full

func (*Buffer[T]) Polling

func (buffer *Buffer[T]) Polling(stopCh <-chan struct{}, handler func(item T))

Polling poll with callback function

type Container

type Container[Key int | string, Value any] struct {
	// contains filtered or unexported fields
}

Container represents a safe map

func NewContainer

func NewContainer[Key int | string, Value any]() *Container[Key, Value]

NewContainer creates a new Container instance

func (*Container[Key, Value]) Del

func (c *Container[Key, Value]) Del(key Key)

Del removes the item from the container

func (*Container[Key, Value]) Get

func (c *Container[Key, Value]) Get(key Key) (item Value, exist bool)

Get returns the value associated

func (*Container[Key, Value]) Set

func (c *Container[Key, Value]) Set(key Key, value Value)

Set sets the value of a key in the container

type Provider

type Provider[Object any] interface {
	Acquire() Object
	Release(obj Object)
}

Provider represents a object provider

func NewSyncPoolProvider

func NewSyncPoolProvider[Object any](constructor func() interface{}) Provider[Object]

type Schema

type Schema struct {
	Protocol string
	Addr     string
}

Schema represents a protocol specification

func NewSchema

func NewSchema(protocol string, addr string) Schema

func (Schema) Listen

func (schema Schema) Listen(stopCh <-chan struct{}, handler func(conn net.Conn)) error

Listen run acceptor with handler

func (Schema) String

func (schema Schema) String() string

String returns a string representation of the schema

type ShardContainer

type ShardContainer[T any] []T

func NewShardContainer

func NewShardContainer[T any](size int, constructor func() T) ShardContainer[T]

func (ShardContainer[T]) GetShard

func (shard ShardContainer[T]) GetShard(num int) T

func (ShardContainer[T]) Iterator

func (shard ShardContainer[T]) Iterator(iterator func(T))

type SyncPoolProvider

type SyncPoolProvider[Object any] struct {
	// contains filtered or unexported fields
}

func (*SyncPoolProvider[Object]) Acquire

func (provider *SyncPoolProvider[Object]) Acquire() Object

func (*SyncPoolProvider[Object]) Release

func (provider *SyncPoolProvider[Object]) Release(obj Object)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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