Class: Euston::DaemonComponentHost

Inherits:
Object
  • Object
show all
Includes:
Euston::Daemons::Exceptions, Hollywood
Defined in:
lib/euston-daemons/euston/daemon_component_host.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Euston::Daemons::Exceptions

#ignorable_exception?

Constructor Details

#initialize(logger, name, client, owner) ⇒ DaemonComponentHost

Returns a new instance of DaemonComponentHost.



6
7
8
# File 'lib/euston-daemons/euston/daemon_component_host.rb', line 6

def initialize logger, name, client, owner
  @log, @name, @client, @owner = logger, name, client, owner
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/euston-daemons/euston/daemon_component_host.rb', line 10

def name
  @name
end

#wait_time=(value) ⇒ Object

Sets the attribute wait_time

Parameters:

  • value

    the value to set the attribute wait_time to.



11
12
13
# File 'lib/euston-daemons/euston/daemon_component_host.rb', line 11

def wait_time=(value)
  @wait_time = value
end

Instance Method Details

#startObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/euston-daemons/euston/daemon_component_host.rb', line 13

def start
  @thread = Thread.new do
    while_thread_is_running do
      begin
        @client.run
      rescue => e
        Thread.current[:exception] = e
      end

      report_exceptions
    end
  end
end

#stopObject



27
28
29
30
# File 'lib/euston-daemons/euston/daemon_component_host.rb', line 27

def stop
  @client.stop
  @thread[:stop] = true
end

#thread_stateObject



32
33
34
# File 'lib/euston-daemons/euston/daemon_component_host.rb', line 32

def thread_state
  @thread.status
end