whenever icon indicating copy to clipboard operation
whenever copied to clipboard

Supported dynamic set variables when proc given.

Open metheglin opened this issue 10 years ago • 2 comments

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 avatar Feb 02 '16 07:02 metheglin

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.

metheglin avatar Feb 02 '16 07:02 metheglin

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

effata avatar Feb 22 '16 10:02 effata