acceptor

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: GPL-3.0 Imports: 10 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 Acceptor

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

func (*Acceptor) Schema

func (acceptor *Acceptor) Schema() Schema

func (*Acceptor) Shutdown

func (acceptor *Acceptor) Shutdown()

type Instance

type Instance interface {
	Schema() Schema
	// Listen runs the thread that will receive the connection
	Listen(onAccept func(conn net.Conn)) error

	// Shutdown shuts down the acceptor
	Shutdown()
}

Instance represents a server for accepting connections

func NewAcceptor

func NewAcceptor(schema Schema, options Options) Instance

type Options

type Options struct {
	Core            int
	ReadBufferSize  int
	WriteBufferSize int
	Keepalive       bool
	WriteDeadline   time.Duration
	ReadDeadline    time.Duration
	LengthOffset    int
}

func DefaultOptions

func DefaultOptions() Options

type Schema

type Schema struct {
	Protocol string
	Addr     string
}

Schema represents a protocol specification

func NewSchema

func NewSchema(protocol string, addr string) Schema

func NewTCPSchema

func NewTCPSchema(addr string) Schema

func NewWebSocketSchema

func NewWebSocketSchema(addr string) Schema

func (Schema) String

func (schema Schema) String() string

String returns a string representation of the schema

type TCPAcceptor

type TCPAcceptor struct {
	*Acceptor
	// contains filtered or unexported fields
}

TCPAcceptor represents tcp acceptor

func (*TCPAcceptor) Listen

func (acceptor *TCPAcceptor) Listen(onAccept func(conn net.Conn)) (err error)

Run runs the acceptor

type WebsocketAcceptor

type WebsocketAcceptor struct {
	*Acceptor
	// contains filtered or unexported fields
}

WebsocketAcceptor represents websocket acceptor

func (*WebsocketAcceptor) Listen

func (acceptor *WebsocketAcceptor) Listen(onAccept func(conn net.Conn)) (err error)

Run runs websocket acceptor

Jump to

Keyboard shortcuts

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