Skip to content

Instantly share code, notes, and snippets.

View carimura's full-sized avatar

Chad Arimura carimura

  • San Francisco, CA
View GitHub Profile
@carimura
carimura / gist:5294704
Last active December 15, 2015 17:09
That should create a task with a timeout of 1 minute.
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
});
@carimura
carimura / iron.json
Last active December 15, 2015 05:09
{
"production": {
"token": "aaaaa",
"project_id": "bbbbbb"
},
"staging": {
"token": "ccccc",
"project_id": "ddddd"
},
"development": {
require 'rest-client'
require 'json'
require 'iron_mq'
license_key = 'my_key'
queue = ironmq.queue("some_active_queue")
size = queue.size
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])
@carimura
carimura / celery.py
Last active December 12, 2015 04:18
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
@carimura
carimura / celery.py
Last active December 12, 2015 03:48
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
@carimura
carimura / tasks.py
Last active December 12, 2015 03:48
from celery import Celery
import iron_celery
celery = Celery('tasks', broker='amqp://guest@localhost//')
@celery.task
def add(x, y):
return x + y
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)
puts "Starting HelloWorker at #{Time.now}"
puts `curl http://ec2-184-72-163-60.compute-1.amazonaws.com --connect-timeout 10`
puts "done"
# 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,