Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lazy option from the configuration option #2931

Merged
merged 6 commits into from
Jul 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
log deprecation warning when using lazy
GustavoCaso committed Jul 5, 2023

Unverified

No user is associated with the committer email.
commit 0cf7c4686fd4a8430c908fa54501b78023715c89
10 changes: 10 additions & 0 deletions lib/datadog/core/configuration/option_definition.rb
Original file line number Diff line number Diff line change
@@ -86,6 +86,15 @@ def helper(name, *_args, &block)
@helpers[name] = block
end

def lazy(_value = true)
Datadog::Core.log_deprecation do
'The `lazy` option is deprecated. You no longer need to specify an option to be lazy '\
"when the default value is a block.\n"\
'In the case edge case that you need the default value to be a block, please use the the expriemntal option:'\
'experimental_default_proc'
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two notes on this:

  • "You no longer need to" should perhaps be "you no longer can" -- this option is gone, it's not that you wouldn't ever need it
  • Is it worth telling people to use the experimental option? Should we instead tell them that we don't support it all until we figure out what we should do?

end

def on_set(&block)
@on_set = block
end
@@ -110,6 +119,7 @@ def apply_options!(options = {})
experimental_default_proc(&options[:experimental_default_proc]) if options.key?(:experimental_default_proc)
delegate_to(&options[:delegate_to]) if options.key?(:delegate_to)
depends_on(*options[:depends_on]) if options.key?(:depends_on)
lazy(options[:lazy]) if options.key?(:lazy)
on_set(&options[:on_set]) if options.key?(:on_set)
resetter(&options[:resetter]) if options.key?(:resetter)
setter(&options[:setter]) if options.key?(:setter)
7 changes: 7 additions & 0 deletions spec/datadog/core/configuration/option_definition_spec.rb
Original file line number Diff line number Diff line change
@@ -315,6 +315,13 @@
end
end

describe '#lazy' do
it 'logs deprecation warning' do
expect(Datadog::Core).to receive(:log_deprecation)
builder.lazy
end
end

describe '#on_set' do
subject(:on_set) { builder.on_set(&block) }