Class: Coatepec::Worker::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/coatepec/worker/server.rb

Overview

The test worker's message loop: reads NDJSON requests from its parent over Protocol, lazily boots Rails on first use, dispatches status/ spec_run, and writes back structured ok/error responses.

Instance Method Summary collapse

Constructor Details

#initialize(project_root, input:, protocol_output:) ⇒ Server

Returns a new instance of Server.



9
10
11
12
13
# File 'lib/coatepec/worker/server.rb', line 9

def initialize(project_root, input:, protocol_output:)
  @protocol = Protocol.new(input: input, output: protocol_output)
  @runtime = RailsRuntime.new(project_root)
  @project_root = project_root
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
# File 'lib/coatepec/worker/server.rb', line 15

def run
  loop do
    message = @protocol.read
    break if message.nil?

    handle(message)
  end
end