Documentation
¶
Overview ¶
Package epoll implements the epoll-based I/O engine for Linux.
Index ¶
- type Engine
- func (e *Engine) Addr() net.Addr
- func (e *Engine) Listen(ctx context.Context) error
- func (e *Engine) Metrics() engine.EngineMetrics
- func (e *Engine) NumWorkers() int
- func (e *Engine) PauseAccept() error
- func (e *Engine) ResumeAccept() error
- func (e *Engine) Shutdown(_ context.Context) error
- func (e *Engine) Type() engine.EngineType
- func (e *Engine) WorkerLoop(n int) engine.WorkerLoop
- type Loop
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine implements the epoll-based I/O engine.
func (*Engine) Metrics ¶
func (e *Engine) Metrics() engine.EngineMetrics
Metrics returns a snapshot of engine metrics.
func (*Engine) NumWorkers ¶ added in v1.4.0
NumWorkers returns the number of worker event loops. Required by engine.EventLoopProvider.
func (*Engine) PauseAccept ¶ added in v0.3.0
PauseAccept stops accepting new connections while keeping existing ones alive.
func (*Engine) ResumeAccept ¶ added in v0.3.0
ResumeAccept starts accepting new connections again. Wakes any suspended loops so they re-create listen sockets.
func (*Engine) Shutdown ¶
Shutdown is a no-op for the epoll engine — graceful shutdown is driven by context cancellation on Listen's parent context. The Server calls Listen with its managed context and cancels it during Server.Shutdown; the Listen goroutine returns after running Loop.shutdown (which closes connections and joins async dispatch goroutines via asyncWG).
The context parameter is accepted for interface parity with engines that do run async drain operations on Shutdown (e.g. std's http.Server.Shutdown), and for future use if epoll Shutdown gains explicit drain semantics.
func (*Engine) WorkerLoop ¶ added in v1.4.0
func (e *Engine) WorkerLoop(n int) engine.WorkerLoop
WorkerLoop returns the worker loop at index n. Panics if n is out of range or if the engine has not yet started listening.
type Loop ¶
type Loop struct {
// contains filtered or unexported fields
}
Loop is an epoll-based event loop worker.
func (*Loop) CPUID ¶ added in v1.4.0
CPUID returns the CPU the worker is pinned to, or -1 if the worker was not successfully pinned (platform.PinToCPU best-effort).
func (*Loop) RegisterConn ¶ added in v1.4.0
RegisterConn adds fd to this worker's epoll interest set and installs the data and close callbacks. fd must already be in non-blocking mode; the caller retains ownership of the fd (UnregisterConn does not close it).
Returns an error if fd is already registered as an HTTP conn on this worker or already registered as a driver conn.
func (*Loop) UnregisterConn ¶ added in v1.4.0
UnregisterConn removes fd from this worker's interest set and schedules the onClose callback (with a nil error) to fire on the next worker iteration. The fd itself is NOT closed — the driver owns its lifetime.
func (*Loop) Write ¶ added in v1.4.0
Write enqueues data for transmission on fd. Returns engine.ErrUnknownFD if fd is not registered on this worker, or engine.ErrQueueFull if the pending backlog would exceed driverWriteCap.
The call is non-blocking: it performs at most one write(2) inline when the socket is idle and otherwise arms EPOLLOUT so the worker flushes the remainder on the next iteration.