Class: Temporal::Activity::Poller

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

Constant Summary collapse

DEFAULT_OPTIONS =
{
  thread_pool_size: 20
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(namespace, task_queue, activity_lookup, middleware = [], options = {}) ⇒ Poller

Returns a new instance of Poller.



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

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

Instance Method Details

#cancel_pending_requestsObject



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

def cancel_pending_requests
  client.cancel_polling_request
end

#startObject



23
24
25
26
# File 'lib/temporal/activity/poller.rb', line 23

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

#stop_pollingObject



28
29
30
31
# File 'lib/temporal/activity/poller.rb', line 28

def stop_polling
  @shutting_down = true
  Temporal.logger.info('Shutting down activity poller', { namespace: namespace, task_queue: task_queue })
end

#waitObject



37
38
39
40
# File 'lib/temporal/activity/poller.rb', line 37

def wait
  thread.join
  thread_pool.shutdown
end