Skip to content

Instantly share code, notes, and snippets.

@bleonard
Created May 2, 2017 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bleonard/27b5f826aca82428b73497cc6a46aa98 to your computer and use it in GitHub Desktop.
Save bleonard/27b5f826aca82428b73497cc6a46aa98 to your computer and use it in GitHub Desktop.
# every minute
subscribe "every_minute", 'bus_event_type' => 'heartbeat_minutes' do |attributes|
InvoiceChargeWorker.process_all!
end
# every hour: 4:22, 5:22, 6:22, etc
subscribe "once_an_hour", 'bus_event_type' => 'heartbeat_minutes', 'minute' => 22 do |attributes|
InvoiceChargeWorker.process_all!
end
# every day at 12:05 am
subscribe "once_a_day", 'bus_event_type' => 'heartbeat_minutes', 'hour' => 0, 'minute' => 5 do |attributes|
InvoiceChargeWorker.process_all!
end
# every monday at 1:52 am
subscribe "early_monday_morning", 'bus_event_type' => 'heartbeat_minutes', 'wday' => 1, 'hour' => 1, 'minute' => 52 do |attributes|
InvoiceChargeWorker.process_all!
end
# the 3rd of every month at 2:10 am
subscribe "once_a_month", 'bus_event_type' => 'heartbeat_minutes', 'day' => 3, 'hour' => 2, 'minute' => 10 do |attributes|
InvoiceChargeWorker.process_all!
end
# every 5 minutes: 4:00, 4:05, 4:10, etc
subscribe "every 5 minutes" do |attributes|
# if it doesn't fit the subscribe pattern, just subscribe to every minute and use ruby
next unless attributes['minute'] % 5 == 0
InvoiceChargeWorker.process_all!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment