Replace IO.select server loop with EventMachine reactor pattern #89

Open
opened 2026-03-15 04:13:07 +00:00 by freemo · 0 comments
Owner

Metadata

  • Commit Message: feat(server): replace IO.select with EventMachine reactor
  • Branch: feature/m1-eventmachine-migration

Background and Context

The current Server#initialize (in lib/aethyr/core/connection/server.rb) runs a
loop do with IO.select(read_array, nil, error_array, SELECT_TIMEOUT) for socket
multiplexing. This must be replaced with EventMachine.run and
EventMachine.start_server for the reactor pattern.

Expected Behavior

  • Server#initialize calls EventMachine.run with a block
  • EventMachine.start_server(address, port, ConnectionHandler) accepts connections
  • The action queue ($manager.pop_action) is drained via an EM periodic timer
  • Display refresh is handled via EM timer

Acceptance Criteria

  • IO.select loop completely removed from server.rb
  • Server starts via EventMachine.run
  • Connections accepted via EventMachine.start_server
  • All existing integration tests pass

Subtasks

  • Refactor server startup to use EventMachine.run
  • Replace socket accept loop with EventMachine.start_server
  • Add EM timer for action queue processing
  • Add EM timer for display refresh
  • Remove legacy IO.select code
  • Run full test suite, fix regressions

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the
    Commit Message in Metadata exactly.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata.
  • The commit is submitted as a pull request to master, reviewed, and merged.
## Metadata - **Commit Message**: `feat(server): replace IO.select with EventMachine reactor` - **Branch**: `feature/m1-eventmachine-migration` ## Background and Context The current `Server#initialize` (in `lib/aethyr/core/connection/server.rb`) runs a `loop do` with `IO.select(read_array, nil, error_array, SELECT_TIMEOUT)` for socket multiplexing. This must be replaced with `EventMachine.run` and `EventMachine.start_server` for the reactor pattern. ## Expected Behavior - `Server#initialize` calls `EventMachine.run` with a block - `EventMachine.start_server(address, port, ConnectionHandler)` accepts connections - The action queue (`$manager.pop_action`) is drained via an EM periodic timer - Display refresh is handled via EM timer ## Acceptance Criteria - `IO.select` loop completely removed from server.rb - Server starts via `EventMachine.run` - Connections accepted via `EventMachine.start_server` - All existing integration tests pass ## Subtasks - [ ] Refactor server startup to use `EventMachine.run` - [ ] Replace socket accept loop with `EventMachine.start_server` - [ ] Add EM timer for action queue processing - [ ] Add EM timer for display refresh - [ ] Remove legacy IO.select code - [ ] Run full test suite, fix regressions ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged**.
freemo added this to the v1.3.0 milestone 2026-03-15 04:13:07 +00:00
freemo self-assigned this 2026-03-15 04:25:23 +00:00
freemo modified the milestone from v1.3.0 to v1.0.0 2026-03-16 00:27:59 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference: aethyr/Aethyr#89
No description provided.