engine

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const MaxDrainSize = 64 * 1024 // 64KB

Variables

View Source
var CtxKeyConnectionState = struct{}{}

Functions

This section is empty.

Types

type ConnectionState

type ConnectionState struct {
	Reader      *bufio.Reader
	Writer      *bufio.Writer
	RemoteAddr  string
	ReadHandler appcontext.ReadHandler
	CancelFunc  context.CancelFunc
	ReadTimeout time.Duration
	Processing  atomic.Bool
	// contains filtered or unexported fields
}

func NewConnectionState

func NewConnectionState(readTimeout time.Duration) *ConnectionState

func (*ConnectionState) Cancel

func (s *ConnectionState) Cancel()

Cancel closes the done channel, simulating context cancellation.

func (*ConnectionState) Deadline

func (s *ConnectionState) Deadline() (deadline time.Time, ok bool)

Deadline implements context.Context

func (*ConnectionState) Done

func (s *ConnectionState) Done() <-chan struct{}

Done implements context.Context

func (*ConnectionState) Err

func (s *ConnectionState) Err() error

Err implements context.Context

func (*ConnectionState) Reset

func (s *ConnectionState) Reset()

func (*ConnectionState) Value

func (s *ConnectionState) Value(key any) any

Value implements context.Context

type Engine

type Engine struct {
	Handler http.Handler
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine(handler http.Handler, opts ...Option) *Engine

func (*Engine) AcquireConnectionState

func (e *Engine) AcquireConnectionState(s *ConnectionState)

AcquireConnectionState increments the reference count. Must be called when entering a goroutine that uses the state.

func (*Engine) ReleaseConnectionState

func (e *Engine) ReleaseConnectionState(s *ConnectionState)

ReleaseConnectionState decrements the reference count. If count reaches 0, resources are returned to the pool. Must be called when leaving a goroutine that uses the state.

func (*Engine) ServeConn

func (e *Engine) ServeConn(ctx context.Context, conn netpoll.Connection) error

type Option

type Option func(*Engine)

func WithBufferSize

func WithBufferSize(size int) Option

func WithMaxDrainSize

func WithMaxDrainSize(size int64) Option

func WithRequestTimeout

func WithRequestTimeout(d time.Duration) Option

Jump to

Keyboard shortcuts

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