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

Supported dynamic set variables when proc given. #607

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

metheglin
Copy link

Let me suggest evaluating procs function when proc is given to a set value.

■Use case example

set :lock_file_name , proc { @options[:task] } # => the task name is set
job_type :runner, "setlock -n /tmp/:lock_file_name bin/rails runner -e :environment ':task' :output"
every :day, at: '11am' do
  runner "TestBatch.run" # => lock_file_name is the same as the task name
end
every :day, at: '11am' do
  runner "TestBatch.run( frequency: :daily )", lock_file_name: "custom_lock_daily" #=> lock_file_name can be over written as the custom name
end

■Why needed?
job_type :runner, "setlock -n /tmp/:task bin/rails runner -e :environment ':task' :output"
is basically good, but not worked in case the task name contains white margin ex: TestBatch.run( frequency: :daily ).
I considered the proc evaluating mechanism is required in order to achieve such issue.
What do you think of this request?

@metheglin
Copy link
Author

In my case, I want to use this feature for lock_file_name of setlock (to protect duplicated execution).
Lock file can't be shared with batches, so I want to avoid the same lock file name could be set.
I'm considering the protection method for such cases.

@effata
Copy link

effata commented Feb 22, 2016

I was looking for exactly this feature, and I would love for this to be merged and released.

@benlangfeld benlangfeld modified the milestone: 0.10.0 Jun 12, 2016

class OutputSetProcTest < Whenever::TestCase

test "Variables which is dynamically set by proc" do
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: Variables which is => Variables which are

Base automatically changed from master to main January 20, 2021 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants