skyrunner 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -2
- data/jobs/example_job.rb +13 -3
- data/lib/generators/sky_runner/install/install_generator.rb +4 -0
- data/lib/generators/sky_runner/install/templates/skyrunner.rake +16 -0
- data/lib/generators/sky_runner/install/templates/skyrunner.rb +2 -0
- data/lib/skyrunner/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de70e60abe085c386c83a7c28304636680a2f6dd
|
4
|
+
data.tar.gz: d80cbea2d0674077f3d731f4de3402f7ff2045c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9408f2d9daf8e8b644625a5e77f9fd933cc734ae611c2a293a27b7b44605c78fc52caca4205e8d5e450bb6d361e27839e5d0ac8033829b3d5dfaead674f915e9
|
7
|
+
data.tar.gz: 8b5410deae5c32154e343e6e09c481d167d01f6c56fe8e3911a1d20dedb27465c963b8fcd97657ac062638f1b6d4bb062b71703694e401e7ebe9ea57918098e1
|
data/README.md
CHANGED
@@ -1,4 +1,37 @@
|
|
1
|
-
|
1
|
+
SkyRunner
|
2
2
|
=========
|
3
3
|
|
4
|
-
|
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
|
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 "
|
35
|
+
puts "Example Job Failed."
|
26
36
|
end
|
27
37
|
end
|
28
38
|
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}"
|
data/lib/skyrunner/version.rb
CHANGED
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.
|
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
|