Class: Wamp::Worker::Runner::Base

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

Overview

This is a base class for all of the runners

Direct Known Subclasses

Background, Main

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, uuid: nil) ⇒ Base

Constructor

Parameters:

  • name (Symbol)
    • the name of the worker



15
16
17
18
19
20
# File 'lib/wamp/worker/runner.rb', line 15

def initialize(name, uuid: nil)
  # Initialize the dispatcher
  @name = name || :default
  @dispatcher = Proxy::Dispatcher.new(self.name, uuid: uuid)
  @active = false
end

Instance Attribute Details

#dispatcherObject (readonly)

Returns the value of attribute dispatcher.



10
11
12
# File 'lib/wamp/worker/runner.rb', line 10

def dispatcher
  @dispatcher
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/wamp/worker/runner.rb', line 10

def name
  @name
end

Instance Method Details

#_startObject

region Override Methods



51
52
# File 'lib/wamp/worker/runner.rb', line 51

def _start
end

#_stopObject



54
55
# File 'lib/wamp/worker/runner.rb', line 54

def _stop
end

#active?Boolean

Returns if the runner is active

Returns:

  • (Boolean)


30
31
32
# File 'lib/wamp/worker/runner.rb', line 30

def active?
  @active
end

#loggerObject

Returns the logger



24
25
26
# File 'lib/wamp/worker/runner.rb', line 24

def logger
  Wamp::Worker.logger
end

#startObject

Starts the runner



36
37
38
39
40
# File 'lib/wamp/worker/runner.rb', line 36

def start
  return if self.active?
  @active = true
  self._start
end

#stopObject

Stops the runner



44
45
46
47
48
# File 'lib/wamp/worker/runner.rb', line 44

def stop
  return unless self.active?
  self._stop
  @active = false
end