skyrunner 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49176f855293135111d70129a79f8f6099d775f6
4
- data.tar.gz: fe7cb68a221e708c668e49f950161f4db9d67542
3
+ metadata.gz: b828d1a9dbc216ff8aca55ce2e8007f07ff1c47d
4
+ data.tar.gz: 21ed7eb84af89b74578726cb69faadc981c6fdf6
5
5
  SHA512:
6
- metadata.gz: ff7a55a80f9a5710ddddcec9b0df187d098557667e49db60c6a90386b7e006b9b08437cb02dd4791396169acc378d44dcf0bc633c582b11f6b62f751fd779538
7
- data.tar.gz: 1df498dd88128acb06800004a76208292881c10e372d180cb2d7f38ef28cb7d8860821aa1f30ee11eaf28971bf2f35159fc7471b0734512d15eaf44cda0099b0
6
+ metadata.gz: f78e396093a0dcbe578b1976911b29e4eab5fdf01ecaffff0405ebbc7394b642923c5b3b47da2da6c4419168cbb8b5932646eddc3391a79c319e43b5b6e44e2a
7
+ data.tar.gz: 43e38c229e0f32c9cddc66ffa375657f96f1e2b8de18e26cf030c14e96a16d065cd813f895281b8eb7ab4cd95fc0807a778117b8f75a8dc8d1766fa0c3c9e25a
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  SkyRunner
2
2
  =========
3
3
 
4
- SkyRunner is a simple job execution framework that lets you run jobs which are composed of small tasks using AWS SQS and DynamoDB.
4
+ SkyRunner is a simple job execution framework that lets you run jobs which are composed of small tasks. SkyRunner uses AWS SQS and DynamoDB for queueing and job coordination, so you don't need any servers other than your task consumers to run jobs.
5
5
 
6
- The key feature provided is that once a job's last task completes, a completion method can be called so you can perform a post-processing step. For example, you may run a job that has 100 tasks that process image frames in parallel, and then when these tasks are completed you compose the frames into a video and upload it to S3.
6
+ The key feature provided is that once a job's last task completes, a completion method can be called so you can perform a post-processing step. For example, you may run a job that has 100 tasks that process image frames in parallel, and then when these tasks are completed you compose the frames into a video and upload it to S3. Of course, you can also execute another job in this method, so you can easily chain jobs together.
7
7
 
8
8
  Add to your Gemfile:
9
9
 
@@ -19,21 +19,27 @@ bundle exec rails g sky_runner:install
19
19
 
20
20
  Customize `config/initializers/skyrunner.rb`. Update `lib/tasks/skyrunner.rake` to do what you want if there are exceptions during a task.
21
21
 
22
+ Put your AWS keys in the usual environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`. If you are running on EC2, you don't need to do this and SkyRunner will run within the machine's IAM role.
23
+
24
+ Be sure the IAM permissions are granted to create DynamoDB tables and SQS queues, and to perform all read and write operations to the table and queue you've configured for SkyRunner.
25
+
22
26
  To initialize DynamoDB & SQS:
23
27
 
24
28
  ``
25
29
  bundle exec rake skyrunner:init
26
30
  ``
27
31
 
28
- To start a consumer
32
+ To start a consumer:
29
33
 
30
34
  ``
31
35
  bundle exec rake skyrunner:consume
32
36
  ``
33
37
 
34
- To gracefully shut down a consumer, send it SIGINT. It will finish up processing the messages it has de-queued before terminating.
38
+ To gracefully shut down a consumer, send it SIGINT (or hit Ctrl-C if you have a console.) It will finish up processing the tasks it has de-queued before terminating.
35
39
 
36
- See `jobs/example_job.rb` for an example job. To run a job, just call `execute!` on the job, passing any named job arguments you want. The job class should implement the method `run`. This method will get passed the job arguments. For each task you want consumers to run, `run` should yield an array of two elements, the first being the name of the method on the job class to run for the task, and the second a Hash of method arguments.
40
+ See `jobs/example_job.rb` for an example job. To run a job, just call `execute!` on the job, passing any named job arguments you want. The job class should implement the method `run`. This method will get passed the job arguments. For each task you want consumers to run, `run` should yield an array of two elements, the first being the name of the method on the job class to run for the task, and the second a Hash of method arguments. Note that the consumer is (by default) multi-threaded, so please be sure your task methods are thread-safe.
37
41
 
38
42
  You can specify `on_complete` and `on_failure` method(s) to call when the tasks are all completed, or if any of them fail, respectively. These methods will also be passed the original job arguments. Importantly, the completion method is guaranteed to be called once and only once, when the final task has been completed.
39
43
 
44
+ If any of your tasks fail in a job, consumers will stop consuming tasks for that job and deplete any queued tasks on SQS. SkyRunner does not currently retry failed tasks, for now you'll need to implement your own retry logic in your task method instead.
45
+
@@ -1,3 +1,3 @@
1
1
  module Skyrunner
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/skyrunner.rb CHANGED
@@ -90,6 +90,7 @@ module SkyRunner
90
90
  job.consume!(task_args)
91
91
  message.delete
92
92
  rescue Exception => e
93
+ message.delete rescue nil
93
94
  error_queue.push(e)
94
95
  SkyRunner::log :error, "Task Failed: #{task_args} Job: #{job_id} #{e.message} #{e.backtrace.join("\n")}"
95
96
  end
@@ -135,9 +136,12 @@ module SkyRunner
135
136
  task_args = message_data["task_args"]
136
137
  local_queue.push([klass, job_id, task_args, message])
137
138
  rescue NameError => e
139
+ message.delete rescue nil
138
140
  log :error, "Task Failed: No such class #{record["class"]} #{e.message}"
139
141
  yield e if block_given?
140
142
  end
143
+ else
144
+ message.delete
141
145
  end
142
146
  end
143
147
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skyrunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Fodor