This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var worker = require("iron_worker"); | |
var client = new worker.Client({"project_id": "my project ID", "token": "my token"}); | |
client.tasksCreate("myWorker", "payload", {"timeout": 60}, function(error, response) { | |
// callback for when the task has been posted, with the response | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"production": { | |
"token": "aaaaa", | |
"project_id": "bbbbbb" | |
}, | |
"staging": { | |
"token": "ccccc", | |
"project_id": "ddddd" | |
}, | |
"development": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest-client' | |
require 'json' | |
require 'iron_mq' | |
license_key = 'my_key' | |
queue = ironmq.queue("some_active_queue") | |
size = queue.size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'iron_mq' | |
def get_client | |
# Set these to your IronMQ credentials | |
config = { | |
token: '', | |
project_id: '' | |
} | |
@ironmq = IronMQ::Client.new(token: config[:token], project_id: config[:project_id]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery import Celery | |
import iron_celery | |
celery = Celery('tasks', | |
broker='ironmq://{iron_project_id}:{iron_token}@' | |
backend='ironcache://{iron_project_id}:{iron_token}@') | |
@celery.task | |
def add(x, y): | |
return x + y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery import Celery | |
import iron_celery | |
celery = Celery('tasks', | |
broker='ironmq://{iron_project_id}:{iron_token}@') | |
@celery.task | |
def add(x, y): | |
return x + y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery import Celery | |
import iron_celery | |
celery = Celery('tasks', broker='amqp://guest@localhost//') | |
@celery.task | |
def add(x, y): | |
return x + y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tasks import add | |
import time | |
start=time.time() | |
for i in range(1000): | |
add.delay(1,i) | |
print "queued job %x" % (i) | |
print "finished in %x seconds" % (time.time() - start) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Starting HelloWorker at #{Time.now}" | |
puts `curl http://ec2-184-72-163-60.compute-1.amazonaws.com --connect-timeout 10` | |
puts "done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Scheduling a task to be queued at a specific time (eg. 1 hour from now) | |
schedule = client.schedules.create('MyWorker', payload, | |
{:start_at => Time.now + 3600}) | |
# Running a task repeatedly (eg. every hour) | |
schedule = client.schedules.create('MyWorker', payload, | |
{:run_every => 3600}) | |
# Scheduling a task to run until a certain time (eg. run 3 hours then stop) | |
schedule = client.schedules.create('MyWorker', payload, |