From c9585026ff2fba2a43e5787ea81ca74fb518e459 Mon Sep 17 00:00:00 2001 From: Ben Standefer Date: Fri, 27 Jun 2025 21:40:19 -0700 Subject: [PATCH] Remove deprecated `Temporal.configuration` function Fixes #143. For a few years there has been a noise `warn` message telling people to not use the function Temporal.configuration, but this function was still used internall in temporal-ruby. The options were: a) Remove the logger warn message, as whoever in the past had planned to deprecate access via `Temporal.configuration` never followed up. I don't know why they were trying to remove this method of accessing it. b) **[CHOSEN OPTION]** Raise the `config` function from `private` to be accessible externally. I don't see why this wouldn't be okay. I ran the tests per the instructions and I get the same amount of test passes, without the noisy deprecation warnings. I don't know the full history that led to this being half-deprecated, but this seems like a fine way to clean it up. --- lib/temporal.rb | 8 ++------ lib/temporal/testing/local_workflow_context.rb | 2 +- lib/temporal/testing/replay_tester.rb | 2 +- lib/temporal/worker.rb | 2 +- spec/unit/lib/temporal_spec.rb | 10 +++------- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/lib/temporal.rb b/lib/temporal.rb index b9f49d55..b35023fd 100644 --- a/lib/temporal.rb +++ b/lib/temporal.rb @@ -56,9 +56,8 @@ def configure(&block) @default_client = nil end - def configuration - warn '[DEPRECATION] This method is now deprecated without a substitution' - config + def config + @config ||= Configuration.new end def logger @@ -75,9 +74,6 @@ def default_client @default_client ||= Client.new(config) end - def config - @config ||= Configuration.new - end end end diff --git a/lib/temporal/testing/local_workflow_context.rb b/lib/temporal/testing/local_workflow_context.rb index 7d3321ae..cf9352ad 100644 --- a/lib/temporal/testing/local_workflow_context.rb +++ b/lib/temporal/testing/local_workflow_context.rb @@ -12,7 +12,7 @@ module Testing class LocalWorkflowContext attr_reader :metadata, :config - def initialize(execution, workflow_id, run_id, disabled_releases, metadata, config = Temporal.configuration) + def initialize(execution, workflow_id, run_id, disabled_releases, metadata, config = Temporal.config) @last_event_id = 0 @execution = execution @run_id = run_id diff --git a/lib/temporal/testing/replay_tester.rb b/lib/temporal/testing/replay_tester.rb index 6a98c86e..9a2724c0 100644 --- a/lib/temporal/testing/replay_tester.rb +++ b/lib/temporal/testing/replay_tester.rb @@ -12,7 +12,7 @@ class ReplayError < StandardError end class ReplayTester - def initialize(config: Temporal.configuration) + def initialize(config: Temporal.config) @config = config end diff --git a/lib/temporal/worker.rb b/lib/temporal/worker.rb index e9a3b2f3..9d73fb93 100644 --- a/lib/temporal/worker.rb +++ b/lib/temporal/worker.rb @@ -33,7 +33,7 @@ class Worker # to be executed once every 10 seconds. This can be used to protect down stream services from # flooding. The zero value of this uses the default value. Default is unlimited. def initialize( - config = Temporal.configuration, + config = Temporal.config, activity_thread_pool_size: Temporal::Activity::Poller::DEFAULT_OPTIONS[:thread_pool_size], workflow_thread_pool_size: Temporal::Workflow::Poller::DEFAULT_OPTIONS[:thread_pool_size], binary_checksum: Temporal::Workflow::Poller::DEFAULT_OPTIONS[:binary_checksum], diff --git a/spec/unit/lib/temporal_spec.rb b/spec/unit/lib/temporal_spec.rb index 49e57664..c2f9494c 100644 --- a/spec/unit/lib/temporal_spec.rb +++ b/spec/unit/lib/temporal_spec.rb @@ -71,14 +71,10 @@ end end - describe '.configuration' do - before { allow(described_class).to receive(:warn) } + describe '.config' do - it 'returns Temporal::Configuration object' do - expect(described_class.configuration).to be_an_instance_of(Temporal::Configuration) - expect(described_class) - .to have_received(:warn) - .with('[DEPRECATION] This method is now deprecated without a substitution') + it 'returns configured Temporal::Configuration object' do + expect(described_class.config).to be_an_instance_of(Temporal::Configuration) end end