Class: Cadence::Activity::Poller

Inherits:
Object
  • Object
show all
Defined in:
lib/cadence/activity/poller.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  thread_pool_size: 20
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(domain, task_list, activity_lookup, middleware = [], options = {}) ⇒ Poller

Returns a new instance of Poller.



13
14
15
16
17
18
19
20
# File 'lib/cadence/activity/poller.rb', line 13

def initialize(domain, task_list, activity_lookup, middleware = [], options = {})
  @domain = domain
  @task_list = task_list
  @activity_lookup = activity_lookup
  @middleware = middleware
  @options = DEFAULT_OPTIONS.merge(options)
  @shutting_down = false
end

Instance Method Details

#startObject



22
23
24
25
# File 'lib/cadence/activity/poller.rb', line 22

def start
  @shutting_down = false
  @thread = Thread.new(&method(:poll_loop))
end

#stopObject



27
28
29
30
# File 'lib/cadence/activity/poller.rb', line 27

def stop
  @shutting_down = true
  Cadence.logger.info('Shutting down activity poller')
end

#waitObject



32
33
34
35
# File 'lib/cadence/activity/poller.rb', line 32

def wait
  thread.join
  thread_pool.shutdown
end