|
13 | 13 | require 'temporalio/internal/worker/workflow_worker' |
14 | 14 | require 'temporalio/worker/activity_executor' |
15 | 15 | require 'temporalio/worker/interceptor' |
| 16 | +require 'temporalio/worker/poller_behavior' |
16 | 17 | require 'temporalio/worker/thread_pool' |
17 | 18 | require 'temporalio/worker/tuner' |
18 | 19 | require 'temporalio/worker/workflow_executor' |
@@ -52,6 +53,8 @@ class Worker |
52 | 53 | :workflow_payload_codec_thread_pool, |
53 | 54 | :unsafe_workflow_io_enabled, |
54 | 55 | :deployment_options, |
| 56 | + :workflow_task_poller_behavior, |
| 57 | + :activity_task_poller_behavior, |
55 | 58 | :debug_mode |
56 | 59 | ) |
57 | 60 |
|
@@ -354,6 +357,10 @@ def self.default_illegal_workflow_calls |
354 | 357 | # with a block for narrower enabling of IO. |
355 | 358 | # @param deployment_options [DeploymentOptions, nil] Deployment options for the worker. |
356 | 359 | # WARNING: This is an experimental feature and may change in the future. |
| 360 | + # @param workflow_task_poller_behavior [PollerBehavior] Specify the behavior of workflow task |
| 361 | + # polling. Defaults to a 5-poller maximum. |
| 362 | + # @param activity_task_poller_behavior [PollerBehavior] Specify the behavior of activity task |
| 363 | + # polling. Defaults to a 5-poller maximum. |
357 | 364 | # @param debug_mode [Boolean] If true, deadlock detection is disabled. Deadlock detection will fail workflow tasks |
358 | 365 | # if they block the thread for too long. This defaults to true if the `TEMPORAL_DEBUG` environment variable is |
359 | 366 | # `true` or `1`. |
@@ -385,6 +392,8 @@ def initialize( |
385 | 392 | workflow_payload_codec_thread_pool: nil, |
386 | 393 | unsafe_workflow_io_enabled: false, |
387 | 394 | deployment_options: Worker.default_deployment_options, |
| 395 | + workflow_task_poller_behavior: PollerBehavior::SimpleMaximum.new(max_concurrent_workflow_task_polls), |
| 396 | + activity_task_poller_behavior: PollerBehavior::SimpleMaximum.new(max_concurrent_activity_task_polls), |
388 | 397 | debug_mode: %w[true 1].include?(ENV['TEMPORAL_DEBUG'].to_s.downcase) |
389 | 398 | ) |
390 | 399 | raise ArgumentError, 'Must have at least one activity or workflow' if activities.empty? && workflows.empty? |
@@ -419,6 +428,8 @@ def initialize( |
419 | 428 | workflow_payload_codec_thread_pool:, |
420 | 429 | unsafe_workflow_io_enabled:, |
421 | 430 | deployment_options:, |
| 431 | + workflow_task_poller_behavior:, |
| 432 | + activity_task_poller_behavior:, |
422 | 433 | debug_mode: |
423 | 434 | ).freeze |
424 | 435 |
|
@@ -446,9 +457,9 @@ def initialize( |
446 | 457 | tuner: tuner._to_bridge_options, |
447 | 458 | identity_override: identity, |
448 | 459 | max_cached_workflows:, |
449 | | - max_concurrent_workflow_task_polls:, |
| 460 | + workflow_task_poller_behavior: workflow_task_poller_behavior._to_bridge_options, |
450 | 461 | nonsticky_to_sticky_poll_ratio:, |
451 | | - max_concurrent_activity_task_polls:, |
| 462 | + activity_task_poller_behavior: activity_task_poller_behavior._to_bridge_options, |
452 | 463 | # For shutdown to work properly, we must disable remote activities |
453 | 464 | # ourselves if there are no activities |
454 | 465 | no_remote_activities: no_remote_activities || activities.empty?, |
|
0 commit comments