Skip to content

feat: standalone mini event loop for driver-only mode #116

@FumingPower3925

Description

@FumingPower3925

Summary

Create a standalone mini event loop that database/cache drivers use when no celeris HTTP server is running. This enables drivers to work independently while still using efficient I/O.

Design

Package: driver/internal/eventloop/

driver/internal/eventloop/
  loop_linux.go    # Standalone mini epoll/iouring loop
  loop_other.go    # Fallback: goroutine-per-conn via net.Conn
  registry.go      # Engine sharing registry

loop_linux.go

  • Stripped-down epoll loop (no accept, no HTTP detection, no protocol parsing)
  • Manages only DB/cache socket FDs
  • Implements the same WorkerLoop interface as the full engines
  • Single-worker by default, configurable via WithWorkers(n)
  • Clean shutdown: drains pending operations, closes all FDs

loop_other.go (non-Linux fallback)

  • Goroutine-per-connection using net.Conn
  • Wraps net.Conn read loop to match WorkerLoop callback semantics
  • Acceptable performance loss on non-Linux (development/testing)

registry.go

  • Global registry where a celeris Server registers its engine as an EventLoopProvider
  • Drivers check registry first — if a provider exists, use integrated mode; otherwise spawn standalone loop
  • Thread-safe with sync.RWMutex

Acceptance Criteria

  • loop_linux.go: functional epoll mini-loop with WorkerLoop interface
  • loop_other.go: goroutine-per-conn fallback compiles on macOS/Windows
  • registry.go: engine sharing registry with register/lookup/deregister
  • Unit tests for both paths
  • No dependency on the full engine packages (only engine/ interfaces)

Metadata

Metadata

Labels

area/driverDatabase/cache driver infrastructurearea/internalInternal packages

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions