Class: Temporal::Workflow::Poller

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

Constant Summary collapse

DEFAULT_OPTIONS =
{
  thread_pool_size: 10
}.freeze

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Poller.



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

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

Instance Method Details

#cancel_pending_requestsObject



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

def cancel_pending_requests
  client.cancel_polling_request
end

#startObject



23
24
25
26
# File 'lib/temporal/workflow/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/workflow/poller.rb', line 28

def stop_polling
  @shutting_down = true
  Temporal.logger.info('Shutting down a workflow poller')
end

#waitObject



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

def wait
  thread.join
  thread_pool.shutdown
end