Skip to content

Instantly share code, notes, and snippets.

@jcap49
Last active January 1, 2016 06:18
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 jcap49/785612f63b8cc0afedea to your computer and use it in GitHub Desktop.
Save jcap49/785612f63b8cc0afedea to your computer and use it in GitHub Desktop.
# text_message.rb --> TextMessage model
class TextMessage < ActiveRecord::Base
# below: a class method to execute a worker
# the IronWorker API takes a few fun params split into
# two distinct sections: the first part of the payload
# handles any params that are useful for the worker during
# runtime - for example, :database is used to pass in
# database credentials for the worker to use;
# the second part of the payload (separated by
# a new hash) is used to define settings for the worker itself
def self.execute_text_message_worker(text_message_id, send_time, user_id)
iron_worker = IronWorkerNG::Client.new
@text_message_worker = iron_worker.schedules.create("Master", {
:text_message_id => text_message_id,
:user_id => user_id,
:database => Rails.configuration.database_configuration[Rails.env],
},{
:start_at => send_time + 5.hours,
:run_every => 3600 * 24,
})
TextMessage.save_text_message_schedule_id(@text_message_worker.id, text_message_id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment