Skip to content

feat: epoll EventLoopProvider implementation (driver FD registration) #114

@FumingPower3925

Description

@FumingPower3925

Summary

Implement the EventLoopProvider and WorkerLoop interfaces on the epoll engine, allowing database/cache driver connections to be registered on epoll workers.

Design

Changes to engine/epoll/loop.go

  • Add driverConns map[int]*driverConn to Loop struct
  • driverConn holds onRecv func([]byte), onClose func(), and a write buffer
  • RegisterConn(fd): adds FD to epoll interest set with EPOLLIN | EPOLLET, stores in driverConns
  • UnregisterConn(fd): removes from epoll, calls onClose, deletes from map
  • Write(fd, data): queues data and adds EPOLLOUT to interest set
  • In the event loop dispatch: check if FD is in driverConns before HTTP conn lookup — call onRecv for EPOLLIN, flush write buffer for EPOLLOUT

Atomic Guard

  • hasDriverConns atomic.Bool on Loop — set to true on first RegisterConn, checked before the driver FD lookup path to avoid map access when no drivers are registered

Acceptance Criteria

  • Epoll Loop implements EventLoopProvider
  • RegisterConn / UnregisterConn / Write work correctly
  • Driver FD events are dispatched to callbacks
  • Zero overhead when no driver connections are registered (atomic guard)
  • Unit tests for registration, data receive, write, and unregistration

Dependencies

  • Depends on 113

Metadata

Metadata

Labels

area/driverDatabase/cache driver infrastructurearea/engineEngine interface or implementationengine/epollEpoll engine specifics

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions