Supported dynamic set variables when proc given.
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?
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.
I was looking for exactly this feature, and I would love for this to be merged and released.