Class: Temporal::Activity::Poller
- Inherits:
-
Object
- Object
- Temporal::Activity::Poller
- Defined in:
- lib/temporal/activity/poller.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ thread_pool_size: 20 }.freeze
Instance Method Summary collapse
- #cancel_pending_requests ⇒ Object
-
#initialize(namespace, task_queue, activity_lookup, middleware = [], options = {}) ⇒ Poller
constructor
A new instance of Poller.
- #start ⇒ Object
- #stop_polling ⇒ Object
- #wait ⇒ Object
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 = [], = {}) @namespace = namespace @task_queue = task_queue @activity_lookup = activity_lookup @middleware = middleware @shutting_down = false @options = DEFAULT_OPTIONS.merge() end |
Instance Method Details
#cancel_pending_requests ⇒ Object
33 34 35 |
# File 'lib/temporal/activity/poller.rb', line 33 def cancel_pending_requests client.cancel_polling_request end |
#start ⇒ Object
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_polling ⇒ Object
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 |
#wait ⇒ Object
37 38 39 40 |
# File 'lib/temporal/activity/poller.rb', line 37 def wait thread.join thread_pool.shutdown end |