Browse files

Some samples for queueing up the gist worker after it's uploaded.

  • Loading branch information...
1 parent b6c7b52 commit 5104201161de17738e293767989bb2ef6546d543 @treeder committed Mar 6, 2012
Showing with 31 additions and 0 deletions.
  1. +2 −0 test/Gemfile
  2. +16 −0 test/queue_via_url.rb
  3. +13 −0 test/queue_via_webhook.rb
View
2 test/Gemfile
@@ -1 +1,3 @@
source 'http://rubygems.org'
+
+gem 'rest'
View
16 test/queue_via_url.rb
@@ -0,0 +1,16 @@
+# After we have our GistWorker uploaded, we may just want to hit the IronWorker url to queue up the task.
+
+require 'yaml'
+require 'rest'
+
+@config = YAML::load_file(File.expand_path(File.join("~", "Dropbox", "configs", "gist_worker", "test", "config.yml")))
+@rest = Rest::Client.new()
+res = @rest.post("https://worker-aws-us-east-1.iron.io/2/projects/#{@config['iron']['project_id']}/tasks?oauth=#{@config['iron']['token']}",
+ :body=>{:tasks=>[
+ 'code_name'=>'GistWorker::Worker',
+ 'payload'=>{'x'=>'abc', 'y'=>123}.to_json
+ ]
+ }.to_json,
+ :headers=>{'Content-Type'=>'application/json'})
+p res
+p res.body
View
13 test/queue_via_webhook.rb
@@ -0,0 +1,13 @@
+# After we have our GistWorker uploaded, we may just want to hit the IronWorker url to queue up the task.
+
+require 'yaml'
+require 'rest'
+
+@config = YAML::load_file(File.expand_path(File.join("~", "Dropbox", "configs", "gist_worker", "test", "config.yml")))
+@rest = Rest::Client.new()
+
+res = @rest.post("https://worker-aws-us-east-1.iron.io/2/projects/#{@config['iron']['project_id']}/tasks/webhook?code_name=GistWorker::Worker&oauth=#{@config['iron']['token']}",
+ :body=>{'x'=>'abc', 'y'=>123}.to_json
+)
+p res
+p res.body

0 comments on commit 5104201

Please sign in to comment.