toiler 0.3.1.beta1 → 0.3.1.beta2

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: ed93f4864147fb62c59bd32d22ed209d61663b8a
4
- data.tar.gz: c9ed6eb3b5b005c7164d1788ab118085027a5ac1
3
+ metadata.gz: e0e6b52aa706f58b4336de5f61a5ee58d1e8fcdd
4
+ data.tar.gz: 25944e01b7f1af554717b8103d12ce6e0488ed4d
5
5
  SHA512:
6
- metadata.gz: 24d7e0230a8fce82a06e4e415d51567445a051a787b7b2f9dc2b5da297a4a5ec9d2ace920c32163a41c54d2da7ddf6da2c206fc810e1b2d38bf1437818edaa05
7
- data.tar.gz: dcb587cd55924cc5ad530c37c2847c93982207499db19adefcec154c78c9e124a2244277fb70f4d6168247f83a2bf32ad96828bdda66edd411d5eb1bc1da6475
6
+ metadata.gz: b7aae208fda6e769b5635ced33b91137968cd2335cb78bdd6bb8f3b04918fde15ef2a8125e56c052da4952ef811460e1c8cd3b53794b19b62466a7880b3330ef
7
+ data.tar.gz: c4304432d894ade81a134e154984a7383f3ed0dbfc172e7e4f92d29d43cf9da61baa37486ed03ebb50b2885f63af2b8114709309d6a558333062a77317ee01e8
data/.gitignore CHANGED
@@ -1,35 +1,35 @@
1
- *.gem
2
- *.rbc
3
- /.config
4
- /coverage/
5
- /InstalledFiles
6
- /pkg/
7
- /spec/reports/
8
- /test/tmp/
9
- /test/version_tmp/
10
- /tmp/
11
-
12
- ## Specific to RubyMotion:
13
- .dat*
14
- .repl_history
15
- build/
16
-
17
- ## Documentation cache and generated files:
18
- /.yardoc/
19
- /_yardoc/
20
- /doc/
21
- /rdoc/
22
-
23
- ## Environment normalisation:
24
- /.bundle/
25
- /vendor/bundle
26
- /lib/bundler/man/
27
-
28
- # for a library or gem, you might want to ignore these files since the code is
29
- # intended to run in multiple environments; otherwise, check them in:
30
- # Gemfile.lock
31
- # .ruby-version
32
- # .ruby-gemset
33
-
34
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
- .rvmrc
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/.gitmodules CHANGED
@@ -1,4 +1,4 @@
1
- [submodule "celluloid-task-pooledfiber"]
2
- path = celluloid-task-pooledfiber
3
- url = git@github.com:celluloid/celluloid-task-pooledfiber.git
4
- branch = 0.2.0-prerelease
1
+ [submodule "celluloid-task-pooledfiber"]
2
+ path = celluloid-task-pooledfiber
3
+ url = git@github.com:celluloid/celluloid-task-pooledfiber.git
4
+ branch = 0.2.0-prerelease
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.2
1
+ 2.2.2
data/Gemfile CHANGED
@@ -1,9 +1,9 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'concurrent-ruby', '~> 1.0.0'
4
- gem 'concurrent-ruby-edge', '~> 0.2.0'
5
- gem 'aws-sdk', '~> 2.2'
6
-
7
- group :development do
8
- gem 'rubocop'
9
- end
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'concurrent-ruby', '~> 1.0.0'
4
+ gem 'concurrent-ruby-edge', '~> 0.2.0'
5
+ gem 'aws-sdk', '~> 2.2'
6
+
7
+ group :development do
8
+ gem 'rubocop'
9
+ end
data/Gemfile.lock CHANGED
@@ -1,41 +1,41 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- ast (2.2.0)
5
- aws-sdk (2.3.7)
6
- aws-sdk-resources (= 2.3.7)
7
- aws-sdk-core (2.3.7)
8
- jmespath (~> 1.0)
9
- aws-sdk-resources (2.3.7)
10
- aws-sdk-core (= 2.3.7)
11
- concurrent-ruby (1.0.2)
12
- concurrent-ruby-edge (0.2.2)
13
- concurrent-ruby (~> 1.0.2)
14
- jmespath (1.2.4)
15
- json_pure (>= 1.8.1)
16
- json_pure (1.8.3)
17
- parser (2.3.1.0)
18
- ast (~> 2.2)
19
- powerpack (0.1.1)
20
- rainbow (2.1.0)
21
- rubocop (0.40.0)
22
- parser (>= 2.3.1.0, < 3.0)
23
- powerpack (~> 0.1)
24
- rainbow (>= 1.99.1, < 3.0)
25
- ruby-progressbar (~> 1.7)
26
- unicode-display_width (~> 1.0, >= 1.0.1)
27
- ruby-progressbar (1.8.1)
28
- unicode-display_width (1.0.5)
29
-
30
- PLATFORMS
31
- ruby
32
- x64-mingw32
33
-
34
- DEPENDENCIES
35
- aws-sdk (~> 2.2)
36
- concurrent-ruby (~> 1.0.0)
37
- concurrent-ruby-edge (~> 0.2.0)
38
- rubocop
39
-
40
- BUNDLED WITH
41
- 1.11.2
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ ast (2.2.0)
5
+ aws-sdk (2.3.7)
6
+ aws-sdk-resources (= 2.3.7)
7
+ aws-sdk-core (2.3.7)
8
+ jmespath (~> 1.0)
9
+ aws-sdk-resources (2.3.7)
10
+ aws-sdk-core (= 2.3.7)
11
+ concurrent-ruby (1.0.2)
12
+ concurrent-ruby-edge (0.2.2)
13
+ concurrent-ruby (~> 1.0.2)
14
+ jmespath (1.2.4)
15
+ json_pure (>= 1.8.1)
16
+ json_pure (1.8.3)
17
+ parser (2.3.1.0)
18
+ ast (~> 2.2)
19
+ powerpack (0.1.1)
20
+ rainbow (2.1.0)
21
+ rubocop (0.40.0)
22
+ parser (>= 2.3.1.0, < 3.0)
23
+ powerpack (~> 0.1)
24
+ rainbow (>= 1.99.1, < 3.0)
25
+ ruby-progressbar (~> 1.7)
26
+ unicode-display_width (~> 1.0, >= 1.0.1)
27
+ ruby-progressbar (1.8.1)
28
+ unicode-display_width (1.0.5)
29
+
30
+ PLATFORMS
31
+ ruby
32
+ x64-mingw32
33
+
34
+ DEPENDENCIES
35
+ aws-sdk (~> 2.2)
36
+ concurrent-ruby (~> 1.0.0)
37
+ concurrent-ruby-edge (~> 0.2.0)
38
+ rubocop
39
+
40
+ BUNDLED WITH
41
+ 1.11.2
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- Copyright (c) Sebastian Schepens
2
-
3
- Toiler is an Open Source project licensed under the terms of
4
- the LGPLv3 license. Please see <http://www.gnu.org/licenses/lgpl-3.0.html>
5
- for license text.
6
-
1
+ Copyright (c) Sebastian Schepens
2
+
3
+ Toiler is an Open Source project licensed under the terms of
4
+ the LGPLv3 license. Please see <http://www.gnu.org/licenses/lgpl-3.0.html>
5
+ for license text.
6
+
data/README.md CHANGED
@@ -1,125 +1,125 @@
1
- ##Toiler
2
- Toiler is a AWS SQS long-polling thread-based message processor.
3
- It's based on [shoryuken](https://github.com/phstc/shoryuken) but takes
4
- a different approach at loadbalancing and uses long-polling.
5
-
6
- ##Features
7
- ###Concurrency
8
- Toiler allows to specify the amount of processors (threads) that should be spawned for each queue.
9
- Instead of [shoryuken's](https://github.com/phstc/shoryuken) loadbalancing approach, Toiler delegates this work to the kernel scheduling threads.
10
-
11
- Because Toiler uses threads to provide concurrency, **each thread instatiates a new worker**, as it should be expected, so please **use class variables to store shared variables like clients**.
12
-
13
- ###Long-Polling
14
- A Fetcher thread is spawned for each queue.
15
- Fetchers are resposible for polling SQS and retreiving messages.
16
- They are optimised to not bring more messages than the amount of processors avaiable for such queue.
17
- By long-polling fetchers wait for a configurable amount of time for messages to become available on a single request, this prevents unneccesarilly requesting messages when there are none.
18
-
19
- ###Message Parsing
20
- Workers can configure a parser Class or Proc to parse an SQS message body before being processed.
21
-
22
- ###Batches
23
- Toiler allows a Worker to be able to receive a batch of messages instead of a single one.
24
-
25
- ###Auto Visibility Extension
26
- Toiler has the ability to automatically extend the visibility timeout of and SQS message to prevent the message from re-entering the queue if processing of such message is taking longer than the queue's visibility timeout.
27
-
28
- ##Instalation
29
-
30
- Add this line to your application's Gemfile:
31
-
32
- ```ruby
33
- gem 'toiler'
34
- ```
35
-
36
- And then execute:
37
-
38
- $ bundle
39
-
40
- Or install it yourself as:
41
-
42
- $ gem install toiler
43
-
44
- ## Usage
45
-
46
- ### Worker class
47
-
48
- ```ruby
49
- class MyWorker
50
- include Toiler::Worker
51
-
52
- toiler_options queue: 'default', concurrency: 5, auto_delete: true
53
- toiler_options parser: :json
54
-
55
- # toiler_options parser: ->(sqs_msg){ REXML::Document.new(sqs_msg.body) }
56
- # toiler_options parser: MultiJson
57
- # toiler_options auto_visibility_timeout: true
58
- # toiler_options batch: true
59
-
60
- #Example connection client that should be shared across all instances of MyWorker
61
- @@client = ConnectionClient.new
62
-
63
- def initialize
64
- @last_message = nil
65
- end
66
-
67
- def perform(sqs_msg, body)
68
- #Workers are thread safe, yay!
69
- #Each worker instance is assured to be processing only one message at a time
70
- @last_message = sqs_msg
71
- puts body
72
- end
73
- end
74
- ```
75
-
76
- ### Configuration
77
-
78
- ```yaml
79
- aws:
80
- access_key_id: ... # or <%= ENV['AWS_ACCESS_KEY_ID'] %>
81
- secret_access_key: ... # or <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
82
- region: us-east-1 # or <%= ENV['AWS_REGION'] %>
83
- wait: 20 # The time in seconds to wait for messages during long-polling
84
- ```
85
-
86
- ### Rails Integration
87
-
88
- You can tell Toiler to load your Rails application by passing the `-R` or `--rails` flag to the "toiler" command.
89
-
90
- If you load Rails, and assuming your workers are located in the `app/workers` directory, they will be auto-loaded. This means you don't need to require them explicitly with `-r`.
91
-
92
-
93
- ### Start Toiler
94
-
95
- ```shell
96
- bundle exec toiler -r worker.rb -C toiler.yml
97
- ```
98
-
99
- Other options:
100
-
101
- ```bash
102
- toiler --help
103
-
104
- -d, --daemon Daemonize process
105
- -r, --require [PATH|DIR] Location of the worker
106
- -C, --config PATH Path to YAML config file
107
- -R, --rails Load Rails
108
- -L, --logfile PATH Path to writable logfile
109
- -P, --pidfile PATH Path to pidfile
110
- -v, --verbose Print more verbose output
111
- -h, --help Show help
112
- ```
113
-
114
-
115
- ## Credits
116
-
117
- Much of the credit goes to [Pablo Cantero](https://github.com/phstc), creator of [Shoryuken](https://github.com/phstc/shoryuken), and [everybody who contributed to it](https://github.com/phstc/shoryuken/graphs/contributors).
118
-
119
- ## Contributing
120
-
121
- 1. Fork it ( https://github.com/sschepens/toiler/fork )
122
- 2. Create your feature branch (`git checkout -b my-new-feature`)
123
- 3. Commit your changes (`git commit -am 'Add some feature'`)
124
- 4. Push to the branch (`git push origin my-new-feature`)
125
- 5. Create a new Pull Request
1
+ ##Toiler
2
+ Toiler is a AWS SQS long-polling thread-based message processor.
3
+ It's based on [shoryuken](https://github.com/phstc/shoryuken) but takes
4
+ a different approach at loadbalancing and uses long-polling.
5
+
6
+ ##Features
7
+ ###Concurrency
8
+ Toiler allows to specify the amount of processors (threads) that should be spawned for each queue.
9
+ Instead of [shoryuken's](https://github.com/phstc/shoryuken) loadbalancing approach, Toiler delegates this work to the kernel scheduling threads.
10
+
11
+ Because Toiler uses threads to provide concurrency, **each thread instatiates a new worker**, as it should be expected, so please **use class variables to store shared variables like clients**.
12
+
13
+ ###Long-Polling
14
+ A Fetcher thread is spawned for each queue.
15
+ Fetchers are resposible for polling SQS and retreiving messages.
16
+ They are optimised to not bring more messages than the amount of processors avaiable for such queue.
17
+ By long-polling fetchers wait for a configurable amount of time for messages to become available on a single request, this prevents unneccesarilly requesting messages when there are none.
18
+
19
+ ###Message Parsing
20
+ Workers can configure a parser Class or Proc to parse an SQS message body before being processed.
21
+
22
+ ###Batches
23
+ Toiler allows a Worker to be able to receive a batch of messages instead of a single one.
24
+
25
+ ###Auto Visibility Extension
26
+ Toiler has the ability to automatically extend the visibility timeout of and SQS message to prevent the message from re-entering the queue if processing of such message is taking longer than the queue's visibility timeout.
27
+
28
+ ##Instalation
29
+
30
+ Add this line to your application's Gemfile:
31
+
32
+ ```ruby
33
+ gem 'toiler'
34
+ ```
35
+
36
+ And then execute:
37
+
38
+ $ bundle
39
+
40
+ Or install it yourself as:
41
+
42
+ $ gem install toiler
43
+
44
+ ## Usage
45
+
46
+ ### Worker class
47
+
48
+ ```ruby
49
+ class MyWorker
50
+ include Toiler::Worker
51
+
52
+ toiler_options queue: 'default', concurrency: 5, auto_delete: true
53
+ toiler_options parser: :json
54
+
55
+ # toiler_options parser: ->(sqs_msg){ REXML::Document.new(sqs_msg.body) }
56
+ # toiler_options parser: MultiJson
57
+ # toiler_options auto_visibility_timeout: true
58
+ # toiler_options batch: true
59
+
60
+ #Example connection client that should be shared across all instances of MyWorker
61
+ @@client = ConnectionClient.new
62
+
63
+ def initialize
64
+ @last_message = nil
65
+ end
66
+
67
+ def perform(sqs_msg, body)
68
+ #Workers are thread safe, yay!
69
+ #Each worker instance is assured to be processing only one message at a time
70
+ @last_message = sqs_msg
71
+ puts body
72
+ end
73
+ end
74
+ ```
75
+
76
+ ### Configuration
77
+
78
+ ```yaml
79
+ aws:
80
+ access_key_id: ... # or <%= ENV['AWS_ACCESS_KEY_ID'] %>
81
+ secret_access_key: ... # or <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
82
+ region: us-east-1 # or <%= ENV['AWS_REGION'] %>
83
+ wait: 20 # The time in seconds to wait for messages during long-polling
84
+ ```
85
+
86
+ ### Rails Integration
87
+
88
+ You can tell Toiler to load your Rails application by passing the `-R` or `--rails` flag to the "toiler" command.
89
+
90
+ If you load Rails, and assuming your workers are located in the `app/workers` directory, they will be auto-loaded. This means you don't need to require them explicitly with `-r`.
91
+
92
+
93
+ ### Start Toiler
94
+
95
+ ```shell
96
+ bundle exec toiler -r worker.rb -C toiler.yml
97
+ ```
98
+
99
+ Other options:
100
+
101
+ ```bash
102
+ toiler --help
103
+
104
+ -d, --daemon Daemonize process
105
+ -r, --require [PATH|DIR] Location of the worker
106
+ -C, --config PATH Path to YAML config file
107
+ -R, --rails Load Rails
108
+ -L, --logfile PATH Path to writable logfile
109
+ -P, --pidfile PATH Path to pidfile
110
+ -v, --verbose Print more verbose output
111
+ -h, --help Show help
112
+ ```
113
+
114
+
115
+ ## Credits
116
+
117
+ Much of the credit goes to [Pablo Cantero](https://github.com/phstc), creator of [Shoryuken](https://github.com/phstc/shoryuken), and [everybody who contributed to it](https://github.com/phstc/shoryuken/graphs/contributors).
118
+
119
+ ## Contributing
120
+
121
+ 1. Fork it ( https://github.com/sschepens/toiler/fork )
122
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
123
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
124
+ 4. Push to the branch (`git push origin my-new-feature`)
125
+ 5. Create a new Pull Request
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require 'bundler/gem_tasks'
1
+ require 'bundler/gem_tasks'
data/bin/toiler CHANGED
@@ -1,12 +1,12 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'toiler'
4
-
5
- begin
6
- Toiler::CLI.instance.run(ARGV)
7
- rescue => e
8
- raise e if $DEBUG
9
- STDERR.puts e.message
10
- STDERR.puts e.backtrace.join("\n")
11
- exit 1
12
- end
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'toiler'
4
+
5
+ begin
6
+ Toiler::CLI.instance.run(ARGV)
7
+ rescue => e
8
+ raise e if $DEBUG
9
+ STDERR.puts e.message
10
+ STDERR.puts e.backtrace.join("\n")
11
+ exit 1
12
+ end