skyrunner 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e461062f35d1a7661bb61f88be54376b55d0d319
4
- data.tar.gz: d346ab60394937f9cdef921cb069c14f0d69fb27
3
+ metadata.gz: de70e60abe085c386c83a7c28304636680a2f6dd
4
+ data.tar.gz: d80cbea2d0674077f3d731f4de3402f7ff2045c2
5
5
  SHA512:
6
- metadata.gz: 04db8b4daecb7d9f56ea0e420bbf259446fbb4264b23306dcc52fa032187fd0ccc9f2ca8c4ce9f2c4a7b332e6e66bde182756cbd2ed969fd7a079a59eef4701b
7
- data.tar.gz: 9d66b4674b4199c5323ec1d70fcfc00d45113d9b7ef75492c4f833908a9bc748d5d1d75b70e8b3dbcdc580ea68b9a7e177414b1eb14e5f5a04bdaa635ef4e5ce
6
+ metadata.gz: 9408f2d9daf8e8b644625a5e77f9fd933cc734ae611c2a293a27b7b44605c78fc52caca4205e8d5e450bb6d361e27839e5d0ac8033829b3d5dfaead674f915e9
7
+ data.tar.gz: 8b5410deae5c32154e343e6e09c481d167d01f6c56fe8e3911a1d20dedb27465c963b8fcd97657ac062638f1b6d4bb062b71703694e401e7ebe9ea57918098e1
data/README.md CHANGED
@@ -1,4 +1,37 @@
1
- skyrunner
1
+ SkyRunner
2
2
  =========
3
3
 
4
- Skyrunner lets you run logical jobs using AWS SQS and DynamoDB
4
+ SkyRunner is a simple job execution framework that lets you run jobs which are composed of small tasks using AWS SQS and DynamoDB.
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.
7
+
8
+ Add to your Gemfile:
9
+
10
+ ```
11
+ gem "skyrunner"
12
+ ```
13
+
14
+ To set up with Rails:
15
+
16
+ ```
17
+ bundle exec rails g sky_runner:install
18
+ ```
19
+
20
+ And customize `config/initializers/skyrunner.rb`
21
+
22
+ To initialize DynamoDB & SQS:
23
+
24
+ ``
25
+ bundle exec rake skyrunner:init
26
+ ``
27
+
28
+ To start a consumer
29
+
30
+ ``
31
+ bundle exec rake skyrunner:consume
32
+ ``
33
+
34
+ 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.
35
+
36
+ You can specify `on_complete` and `on_failure` methods 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.
37
+
data/jobs/example_job.rb CHANGED
@@ -1,5 +1,11 @@
1
1
  require "skyrunner"
2
2
 
3
+ # Example job.
4
+ #
5
+ # To run:
6
+ #
7
+ # ExampleJobModule::ExampleJob.new.execute!(number_of_tasks: 7)
8
+ #
3
9
  module ExampleJobModule
4
10
  class ExampleJob
5
11
  include SkyRunner::Job
@@ -8,21 +14,25 @@ module ExampleJobModule
8
14
  on_failed :print_failed
9
15
 
10
16
  def run(number_of_tasks: nil)
17
+ # Yield the method and arguments you want to call for each task.
18
+ #
19
+ # The number of times this method yields is the number of tasks that consumers
20
+ # will run.
11
21
  1.upto(number_of_tasks).each do |n|
12
22
  yield :print_number, task_number: n
13
23
  end
14
24
  end
15
25
 
16
26
  def print_number(task_number: nil)
17
- puts "Ran rask #{task_number}"
27
+ puts "Ran task #{task_number}"
18
28
  end
19
29
 
20
30
  def print_completed(number_of_tasks: nil)
21
- puts "Completed with #{number_of_tasks}"
31
+ puts "Completed with #{number_of_tasks} tasks requested."
22
32
  end
23
33
 
24
34
  def print_failed(number_of_tasks: nil)
25
- puts "Failed with #{number_of_tasks}"
35
+ puts "Example Job Failed."
26
36
  end
27
37
  end
28
38
  end
@@ -21,6 +21,10 @@ module SkyRunner
21
21
  def create_initializer_file
22
22
  copy_file "skyrunner.rb", "config/initializers/skyrunner.rb"
23
23
  end
24
+
25
+ def create_rake_tasks
26
+ copy_file "skyrunner.rake", "lib/tasks/skyrunner.rake"
27
+ end
24
28
  end
25
29
  end
26
30
  end
@@ -0,0 +1,16 @@
1
+ namespace :skyrunner do
2
+ desc "Starts consuming SkyRunner tasks."
3
+ task init: :environment do
4
+ SkyRunner.init!
5
+ end
6
+
7
+ desc "Creates DynamoDB table and SQS queue for SkyRunner."
8
+ task consume: :environment do
9
+ SkyRunner.consume!
10
+ end
11
+
12
+ desc "Purges and re-creates DynamoDB table and SQS queue for SkyRunner. (Warning: destructive!)"
13
+ task purge: :environment do
14
+ SkyRunner.purge!
15
+ end
16
+ end
@@ -1,4 +1,6 @@
1
1
  SkyRunner.setup do |config|
2
+ config.logger = Rails.logger
3
+
2
4
  # Customize these to change the name of the table & queue used for job and task management.
3
5
  config.dynamo_db_table_name = "skyrunner_jobs_#{Rails.env}"
4
6
  config.sqs_queue_name = "skyrunner_tasks_#{Rails.env}"
@@ -1,3 +1,3 @@
1
1
  module Skyrunner
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  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.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Fodor
@@ -111,6 +111,7 @@ files:
111
111
  - bin/skyrunner
112
112
  - jobs/example_job.rb
113
113
  - lib/generators/sky_runner/install/install_generator.rb
114
+ - lib/generators/sky_runner/install/templates/skyrunner.rake
114
115
  - lib/generators/sky_runner/install/templates/skyrunner.rb
115
116
  - lib/skyrunner.rb
116
117
  - lib/skyrunner/engine.rb