Class: RubyWolf::Worker

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ Worker

Returns a new instance of Worker.



5
6
7
8
9
10
# File 'lib/ruby_wolf/worker.rb', line 5

def initialize(server)
  @server = server
  @app = server.app
  @socket = server.socket
  @connections = []
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



3
4
5
# File 'lib/ruby_wolf/worker.rb', line 3

def app
  @app
end

#connectionsObject (readonly)

Returns the value of attribute connections.



3
4
5
# File 'lib/ruby_wolf/worker.rb', line 3

def connections
  @connections
end

#pidObject (readonly)

Returns the value of attribute pid.



3
4
5
# File 'lib/ruby_wolf/worker.rb', line 3

def pid
  @pid
end

#serverObject (readonly)

Returns the value of attribute server.



3
4
5
# File 'lib/ruby_wolf/worker.rb', line 3

def server
  @server
end

#socketObject (readonly)

Returns the value of attribute socket.



3
4
5
# File 'lib/ruby_wolf/worker.rb', line 3

def socket
  @socket
end

Instance Method Details

#startObject



12
13
14
15
16
17
# File 'lib/ruby_wolf/worker.rb', line 12

def start
  @pid = fork do
    RubyWolf.log('Worker is ready')
    handle_loop
  end
end