fifo 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/LICENSE.txt +20 -0
- data/README.textile +234 -0
- data/Rakefile +70 -0
- data/VERSION +1 -0
- data/lib/fifo.rb +8 -0
- data/lib/fifo/payload.rb +91 -0
- data/lib/fifo/queue.rb +79 -0
- data/lib/fifo/queue_manager.rb +42 -0
- data/test/helper.rb +18 -0
- data/test/test_fifo.rb +7 -0
- metadata +168 -0
data/.document
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Siddharth Batra
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,234 @@
|
|
1
|
+
h1. FIFO
|
2
|
+
|
3
|
+
FIFO is a ruby queueing library built on top of Amazon SQS (Simple Queue Service). Like DelayedJob it encapsulates the common pattern of executing time consuming tasks in the background but unlike DelayedJob it doesn't rely on a database.
|
4
|
+
|
5
|
+
h3. Features
|
6
|
+
* Built on Amazon's reliable and scalable queue service.
|
7
|
+
* Connection to SQS are opened lazily negating any initial load time.
|
8
|
+
* Use multiple queues with ease.
|
9
|
+
* Doesn't poll the database.
|
10
|
+
* Rails ActiveRecord objects maintain state through the queue.
|
11
|
+
* Built-in retry mechanism.
|
12
|
+
|
13
|
+
h3. Uses
|
14
|
+
|
15
|
+
FIFO is extracted from the Mine (http://getmine.com) codebase. Here are some of the things we use it for:
|
16
|
+
|
17
|
+
* Sending emails
|
18
|
+
* Processing images
|
19
|
+
* Indexing
|
20
|
+
* Sharing to social networks
|
21
|
+
* Cache management
|
22
|
+
* Launching cron jobs
|
23
|
+
* Communicate between disjoint parts of a complex application (cron, web, processing servers)
|
24
|
+
|
25
|
+
h2. Installation
|
26
|
+
|
27
|
+
<pre>
|
28
|
+
Pending
|
29
|
+
</pre>
|
30
|
+
|
31
|
+
|
32
|
+
h2. Usage
|
33
|
+
|
34
|
+
|
35
|
+
h3. Credentials
|
36
|
+
|
37
|
+
Setup an aws access id and aws secret key. They can be found here: https://portal.aws.amazon.com/gp/aws/securityCredentials
|
38
|
+
|
39
|
+
<pre>
|
40
|
+
FIFO::QueueManager.setup <aws_access_id>, <aws_secret_key>
|
41
|
+
</pre>
|
42
|
+
|
43
|
+
|
44
|
+
h3. Initialization
|
45
|
+
|
46
|
+
Create a queue object. If an queue by this name doesn't exist on the Amazon SQS account this will create one.
|
47
|
+
|
48
|
+
For Rails, this can be added to a file in "config/initializers/". Additionally, queue names can include the current Rails environment name for modularity.
|
49
|
+
|
50
|
+
There is an additional parameter for message visibility. For more details see: http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/Welcome.html
|
51
|
+
|
52
|
+
<pre>
|
53
|
+
queue = FIFO::Queue.new <queue_name>
|
54
|
+
</pre>
|
55
|
+
|
56
|
+
To prevent delays at the start of the application SQS connections are opened lazily. This saves the overheard when initialzing multiple queues:
|
57
|
+
|
58
|
+
<pre>
|
59
|
+
queues = []
|
60
|
+
(1..10).each do |i|
|
61
|
+
queues << FIFO::Queue.new <queue_name_i>
|
62
|
+
end
|
63
|
+
</pre>
|
64
|
+
|
65
|
+
h3. Insertion
|
66
|
+
|
67
|
+
The most basic case takes a Ruby object, a method to be called and a list of method parameters. Example of a ruby command and how to run it in the background:
|
68
|
+
|
69
|
+
<pre>
|
70
|
+
"World".insert 0,"Hello "
|
71
|
+
|
72
|
+
queue.push "World",:insert,0,"Hello "
|
73
|
+
</pre>
|
74
|
+
|
75
|
+
|
76
|
+
FIFO is designed to work with ActiveRecord objects. Freshness of ActiveRecord objects is ensured by reloading them from the database when they're popped from the queue. Consider an instance method to process images:
|
77
|
+
|
78
|
+
<pre>
|
79
|
+
user.process_profile_image {:max_width => 200,:max_height => 150}
|
80
|
+
|
81
|
+
queue.push user,:process_profile_image,{:max_width => 200,:max_height => 150}
|
82
|
+
</pre>
|
83
|
+
|
84
|
+
|
85
|
+
FIFO also works with ActiveRecord class methods. For example, sending newsletters:
|
86
|
+
|
87
|
+
<pre>
|
88
|
+
UserMailer.deliver_newsletter emails
|
89
|
+
|
90
|
+
queue.push UserMailer,:deliver_newsletter,emails
|
91
|
+
</pre>
|
92
|
+
|
93
|
+
|
94
|
+
h3. Processing
|
95
|
+
|
96
|
+
Every item pushed into the queue is converted into a FIFO::Payload object which executes the passed method.
|
97
|
+
|
98
|
+
Basic flow of processing an item from the queue:
|
99
|
+
|
100
|
+
<pre>
|
101
|
+
queue.push "Hello World",:length
|
102
|
+
payload = queue.pop
|
103
|
+
payload.process
|
104
|
+
=> 11
|
105
|
+
</pre>
|
106
|
+
|
107
|
+
Retry functionality takes a failed payload and adds it back into the queue. Payload objects maintain total number of processing attempts.
|
108
|
+
|
109
|
+
<pre>
|
110
|
+
queue.push "Hello World",:length
|
111
|
+
|
112
|
+
begin
|
113
|
+
payload = queue.pop
|
114
|
+
payload.process
|
115
|
+
rescue => ex
|
116
|
+
payload.retry if payload.attempts < 3
|
117
|
+
end
|
118
|
+
</pre>
|
119
|
+
|
120
|
+
|
121
|
+
Process all items in the queue:
|
122
|
+
|
123
|
+
<pre>
|
124
|
+
while(true)
|
125
|
+
payload = queue.pop
|
126
|
+
break unless payload
|
127
|
+
|
128
|
+
begin
|
129
|
+
payload.process
|
130
|
+
rescue => ex
|
131
|
+
payload.retry if payload.attempts < 3
|
132
|
+
end
|
133
|
+
end
|
134
|
+
</pre>
|
135
|
+
|
136
|
+
Multiple queues can be used to simulate priority:
|
137
|
+
|
138
|
+
<pre>
|
139
|
+
while(true)
|
140
|
+
payload = queue.pop
|
141
|
+
payload = queue1.pop unless payload
|
142
|
+
payload = queue2.pop unless payload
|
143
|
+
|
144
|
+
begin
|
145
|
+
payload.process
|
146
|
+
rescue => ex
|
147
|
+
payload.retry if payload.attempts < 3
|
148
|
+
end
|
149
|
+
|
150
|
+
sleep 10
|
151
|
+
end
|
152
|
+
</pre>
|
153
|
+
|
154
|
+
|
155
|
+
The Payload flow can be entirely skipped by popping the raw response from the queue:
|
156
|
+
|
157
|
+
<pre>
|
158
|
+
queue.pop :raw => true
|
159
|
+
</pre>
|
160
|
+
|
161
|
+
|
162
|
+
h4. Daemon
|
163
|
+
|
164
|
+
h5. Installation
|
165
|
+
|
166
|
+
<pre>
|
167
|
+
sudo gem install daemons
|
168
|
+
Install daemon_generator from: https://github.com/dougal/daemon_generator
|
169
|
+
|
170
|
+
./script/generate daemon <name>
|
171
|
+
</pre>
|
172
|
+
|
173
|
+
h5. Source
|
174
|
+
|
175
|
+
<pre>
|
176
|
+
require File.dirname(__FILE__) + "/../../config/environment"
|
177
|
+
|
178
|
+
$running = true
|
179
|
+
Signal.trap("TERM") do
|
180
|
+
$running = false
|
181
|
+
end
|
182
|
+
|
183
|
+
FIFO::QueueManager.setup <aws_access_id>, <aws_secret_key>
|
184
|
+
|
185
|
+
queue = FIFO::Queue.new <queue_name>
|
186
|
+
logger = Logger.new(File.join(RAILS_ROOT,"log/<name>.rb.log"))
|
187
|
+
|
188
|
+
|
189
|
+
while($running) do
|
190
|
+
payload = queue.pop
|
191
|
+
|
192
|
+
if payload
|
193
|
+
|
194
|
+
begin
|
195
|
+
start_time = Time.now
|
196
|
+
payload.process
|
197
|
+
end_time = Time.now
|
198
|
+
|
199
|
+
logger.info "Finished #{payload.to_s} #{end_time - start_time}"
|
200
|
+
|
201
|
+
rescue => ex
|
202
|
+
if payload.attempts < 3
|
203
|
+
logger.info "Recovering #{payload.to_s}"
|
204
|
+
payload.retry
|
205
|
+
else
|
206
|
+
#Log Exception
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
sleep 5
|
213
|
+
end
|
214
|
+
</pre>
|
215
|
+
|
216
|
+
To control the state of the daemon:
|
217
|
+
|
218
|
+
<pre>
|
219
|
+
lib/daemon/<name>_ctl <start|stop|run>
|
220
|
+
</pre>
|
221
|
+
|
222
|
+
h2. SQS
|
223
|
+
|
224
|
+
Things to know about Amazon's SQS:
|
225
|
+
|
226
|
+
* The order of items isn't always maintained. It's not 100% fifo but close enough.
|
227
|
+
* There are multiple connection modes to SQS: per_request, per_thread, single
|
228
|
+
* http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/Welcome.html
|
229
|
+
|
230
|
+
|
231
|
+
h2. Credit
|
232
|
+
|
233
|
+
FIFO is built by the wonderful people who make Mine: http://getmine.com
|
234
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |gem|
|
8
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
9
|
+
gem.name = "fifo"
|
10
|
+
gem.homepage = "http://github.com/denwen/fifo"
|
11
|
+
gem.license = "MIT"
|
12
|
+
gem.summary = %Q{Queueing library in Ruby built on top of Amazon SQS (Simple Queue Service).}
|
13
|
+
gem.description = %Q{Queueing library in Ruby built on top of Amazon SQS(Simple Queue Service) for processing background tasks and enabling communication between parts of a complex application.}
|
14
|
+
gem.email = "siddharthabatra@gmail.com"
|
15
|
+
gem.authors = ["Siddharth Batra"]
|
16
|
+
gem.add_runtime_dependency 'aws', '>= 2.5.6'
|
17
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
18
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
19
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
20
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
21
|
+
gem.add_development_dependency "shoulda", ">= 0"
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
gem.add_development_dependency "rdoc", "~> 3.12"
|
27
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
28
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
29
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
30
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
31
|
+
gem.add_development_dependency "bundler", "~> 1.0.0"
|
32
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
33
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
34
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
35
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
36
|
+
gem.add_development_dependency "jeweler", "~> 1.8.3"
|
37
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
38
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
39
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
40
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
41
|
+
gem.add_development_dependency "rcov", ">= 0"
|
42
|
+
end
|
43
|
+
Jeweler::RubygemsDotOrgTasks.new
|
44
|
+
|
45
|
+
require 'rake/testtask'
|
46
|
+
Rake::TestTask.new(:test) do |test|
|
47
|
+
test.libs << 'lib' << 'test'
|
48
|
+
test.pattern = 'test/**/test_*.rb'
|
49
|
+
test.verbose = true
|
50
|
+
end
|
51
|
+
|
52
|
+
require 'rcov/rcovtask'
|
53
|
+
Rcov::RcovTask.new do |test|
|
54
|
+
test.libs << 'test'
|
55
|
+
test.pattern = 'test/**/test_*.rb'
|
56
|
+
test.verbose = true
|
57
|
+
test.rcov_opts << '--exclude "gems/*"'
|
58
|
+
end
|
59
|
+
|
60
|
+
task :default => :test
|
61
|
+
|
62
|
+
require 'rdoc/task'
|
63
|
+
Rake::RDocTask.new do |rdoc|
|
64
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
65
|
+
|
66
|
+
rdoc.rdoc_dir = 'rdoc'
|
67
|
+
rdoc.title = "fifo #{version}"
|
68
|
+
rdoc.rdoc_files.include('README*')
|
69
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
70
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
data/lib/fifo.rb
ADDED
data/lib/fifo/payload.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
module FIFO
|
2
|
+
|
3
|
+
class Payload
|
4
|
+
attr_accessor :queue
|
5
|
+
attr_reader :attempts
|
6
|
+
|
7
|
+
# Public. Create a payload with an object a method of that
|
8
|
+
# object and optional arguments for that method.
|
9
|
+
#
|
10
|
+
# object - The Object the payload carries.
|
11
|
+
# method - The Symbol method name for the object.
|
12
|
+
# args - The optional array of arguments for the method.
|
13
|
+
#
|
14
|
+
# Returns nothing.
|
15
|
+
# Raises ArgumentError if object or method aren't present.
|
16
|
+
def initialize(object,method,*args)
|
17
|
+
raise ArgumentError, "object and method required" unless object && method
|
18
|
+
|
19
|
+
@attempts = 1
|
20
|
+
@object = object.is_a?(Class) ?
|
21
|
+
object.to_s.split("::").last :
|
22
|
+
object.to_yaml
|
23
|
+
@method = method
|
24
|
+
@arguments = args
|
25
|
+
end
|
26
|
+
|
27
|
+
# Public. Call the method on the carried object with
|
28
|
+
# the carried arguments. If the carried object is an
|
29
|
+
# ActiveRecord::Base object, reload it from the db
|
30
|
+
# to get a fresh state.
|
31
|
+
#
|
32
|
+
# Returns the result of the method call on the object.
|
33
|
+
def process
|
34
|
+
if is_object_yaml?
|
35
|
+
object = YAML.load(@object)
|
36
|
+
|
37
|
+
if defined?(ActiveRecord) && object.is_a?(ActiveRecord::Base)
|
38
|
+
object = object.class.find object.id
|
39
|
+
end
|
40
|
+
else
|
41
|
+
object = Object.const_get(@object)
|
42
|
+
end
|
43
|
+
|
44
|
+
object.send(@method.to_sym,*@arguments)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Public. Mark the instance as failed by increaseing
|
48
|
+
# the number of attempts to process it.
|
49
|
+
#
|
50
|
+
# Returns the Integer number of attempts used.
|
51
|
+
def failed
|
52
|
+
@attempts += 1
|
53
|
+
end
|
54
|
+
|
55
|
+
# Public. Add the payload back onto the queue.
|
56
|
+
#
|
57
|
+
def retry
|
58
|
+
failed
|
59
|
+
queue.push self
|
60
|
+
end
|
61
|
+
|
62
|
+
# Public. Override to_s for a loggable output.
|
63
|
+
#
|
64
|
+
# Returns the String form of the Payload.
|
65
|
+
def to_s
|
66
|
+
output = ""
|
67
|
+
|
68
|
+
if is_object_yaml?
|
69
|
+
object = YAML.load(@object)
|
70
|
+
output << object.class.name
|
71
|
+
else
|
72
|
+
output << Object.const_get(@object).name
|
73
|
+
end
|
74
|
+
|
75
|
+
output << " :#{@method} #{@arguments.join("|")}"
|
76
|
+
output
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
# Private. Test if the object is a ruby object in YAML.
|
83
|
+
#
|
84
|
+
# Returns the Boolean value of the test.
|
85
|
+
def is_object_yaml?
|
86
|
+
@object.start_with? "--- "
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
data/lib/fifo/queue.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
module FIFO
|
2
|
+
|
3
|
+
class Queue
|
4
|
+
|
5
|
+
# Public. Constructor logic.
|
6
|
+
#
|
7
|
+
# name - The String name of the queue.
|
8
|
+
# visibility - The Integer visibility of an item in the queue.
|
9
|
+
#
|
10
|
+
# Returns nothing.
|
11
|
+
def initialize(name,visibility=90)
|
12
|
+
@name = name
|
13
|
+
@visibility = visibility
|
14
|
+
end
|
15
|
+
|
16
|
+
# Public. Pop the first entry in the queue and create a payload
|
17
|
+
# object from it.
|
18
|
+
#
|
19
|
+
# options - The Hash of options.
|
20
|
+
# :raw - Return raw queue value instead of a payload.
|
21
|
+
#
|
22
|
+
# Returns the Payload object if found or nil.
|
23
|
+
def pop(options={})
|
24
|
+
message = queue.pop
|
25
|
+
|
26
|
+
if message
|
27
|
+
if options[:raw]
|
28
|
+
payload = message.body
|
29
|
+
else
|
30
|
+
payload = YAML.load(message.body)
|
31
|
+
payload.queue = self
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
payload
|
36
|
+
end
|
37
|
+
|
38
|
+
# Push a new entry onto the queue.
|
39
|
+
#
|
40
|
+
# args - This can either be a Payload object or a Class or any ruby object
|
41
|
+
# including ActiveRecord::Base objects followed by a symbol for a method and optional
|
42
|
+
# method arguments. During processing ActiveRecord::Base
|
43
|
+
# objects are fetched again from the DB to avoid staleness.
|
44
|
+
#
|
45
|
+
# Returns nothing.
|
46
|
+
def push(*args)
|
47
|
+
payload = nil
|
48
|
+
|
49
|
+
if args.first.class == Payload
|
50
|
+
payload = args.first
|
51
|
+
payload.queue = nil
|
52
|
+
else
|
53
|
+
payload = Payload.new(*args)
|
54
|
+
end
|
55
|
+
|
56
|
+
queue.push(payload.to_yaml)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Public: Clear all entries in the queue.
|
60
|
+
#
|
61
|
+
# Returns nothing.
|
62
|
+
def clear
|
63
|
+
queue.clear
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
# Private. Getter method for the queue. Enables opening
|
70
|
+
# lazy connections.
|
71
|
+
#
|
72
|
+
# Returns the Aws::Sqs::Queue object the QueueManager creates.
|
73
|
+
def queue
|
74
|
+
@queue ||= QueueManager.fetch(@name,@visibility)
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module FIFO
|
2
|
+
|
3
|
+
class QueueManager
|
4
|
+
|
5
|
+
# Public. Setup AWS credentials and connection_mode for the service.
|
6
|
+
#
|
7
|
+
# aws_access_id - The String AWS access id.
|
8
|
+
# aws_secret_key - The String AWS secret key.
|
9
|
+
# connection_mode - The Symbol for threading options -
|
10
|
+
# :single,:per_thread,:per_request.
|
11
|
+
# See: https://github.com/appoxy/aws/ (default: :single)
|
12
|
+
#
|
13
|
+
def self.setup(aws_access_id,aws_secret_key,connection_mode=:single)
|
14
|
+
@aws_access_id = aws_access_id
|
15
|
+
@aws_secret_key = aws_secret_key
|
16
|
+
@connection_mode = connection_mode
|
17
|
+
end
|
18
|
+
|
19
|
+
# Public. Open a connection and fetch an Aws::Sqs::Queue.
|
20
|
+
#
|
21
|
+
# Returns the Aws::Sqs::Queue.
|
22
|
+
def self.fetch(name,visibility)
|
23
|
+
Aws::Sqs::Queue.create(sqs,name,true,visibility)
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
# Private: Getter method for Aws::Sqs object. Enables
|
30
|
+
# lazily creating an SqsInterface.
|
31
|
+
#
|
32
|
+
# Returns the Aws::Sqs.
|
33
|
+
def self.sqs
|
34
|
+
@sqs ||= Aws::Sqs.new(
|
35
|
+
@aws_access_id,
|
36
|
+
@aws_secret_key,
|
37
|
+
{:connection_mode => @connection_mode})
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'fifo'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
data/test/test_fifo.rb
ADDED
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fifo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Siddharth Batra
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-10-17 00:00:00 +00:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: aws
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 23
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 5
|
33
|
+
- 6
|
34
|
+
version: 2.5.6
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: shoulda
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rdoc
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 31
|
60
|
+
segments:
|
61
|
+
- 3
|
62
|
+
- 12
|
63
|
+
version: "3.12"
|
64
|
+
type: :development
|
65
|
+
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: bundler
|
68
|
+
prerelease: false
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 23
|
75
|
+
segments:
|
76
|
+
- 1
|
77
|
+
- 0
|
78
|
+
- 0
|
79
|
+
version: 1.0.0
|
80
|
+
type: :development
|
81
|
+
version_requirements: *id004
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: jeweler
|
84
|
+
prerelease: false
|
85
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ~>
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 49
|
91
|
+
segments:
|
92
|
+
- 1
|
93
|
+
- 8
|
94
|
+
- 3
|
95
|
+
version: 1.8.3
|
96
|
+
type: :development
|
97
|
+
version_requirements: *id005
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rcov
|
100
|
+
prerelease: false
|
101
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
type: :development
|
111
|
+
version_requirements: *id006
|
112
|
+
description: Queueing library in Ruby built on top of Amazon SQS(Simple Queue Service) for processing background tasks and enabling communication between parts of a complex application.
|
113
|
+
email: siddharthabatra@gmail.com
|
114
|
+
executables: []
|
115
|
+
|
116
|
+
extensions: []
|
117
|
+
|
118
|
+
extra_rdoc_files:
|
119
|
+
- LICENSE.txt
|
120
|
+
- README.textile
|
121
|
+
files:
|
122
|
+
- .document
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.textile
|
125
|
+
- Rakefile
|
126
|
+
- VERSION
|
127
|
+
- lib/fifo.rb
|
128
|
+
- lib/fifo/payload.rb
|
129
|
+
- lib/fifo/queue.rb
|
130
|
+
- lib/fifo/queue_manager.rb
|
131
|
+
- test/helper.rb
|
132
|
+
- test/test_fifo.rb
|
133
|
+
has_rdoc: true
|
134
|
+
homepage: http://github.com/denwen/fifo
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
none: false
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
hash: 3
|
148
|
+
segments:
|
149
|
+
- 0
|
150
|
+
version: "0"
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
none: false
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
hash: 3
|
157
|
+
segments:
|
158
|
+
- 0
|
159
|
+
version: "0"
|
160
|
+
requirements: []
|
161
|
+
|
162
|
+
rubyforge_project:
|
163
|
+
rubygems_version: 1.5.2
|
164
|
+
signing_key:
|
165
|
+
specification_version: 3
|
166
|
+
summary: Queueing library in Ruby built on top of Amazon SQS (Simple Queue Service).
|
167
|
+
test_files: []
|
168
|
+
|