iron_mq 1.9.1 → 2.0.0
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.
- data/Gemfile.lock +32 -8
- data/iron_mq.gemspec +3 -2
- data/lib/iron_mq/client.rb +20 -9
- data/lib/iron_mq/version.rb +1 -1
- data/lib/iron_mq.rb +1 -0
- data/test/long_run.rb +7 -7
- data/test/long_run_worker.rb +8 -6
- data/test/test_base.rb +6 -0
- data/test/test_bulk.rb +33 -0
- data/test/test_iron_mq.rb +9 -9
- metadata +38 -10
- data/test/Gemfile +0 -6
- data/test/Gemfile.lock +0 -48
- data/test/test_push_queues.rb +0 -32
data/Gemfile.lock
CHANGED
@@ -1,25 +1,47 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
iron_mq (1.9.
|
5
|
-
iron_core (>= 0.
|
4
|
+
iron_mq (1.9.1)
|
5
|
+
iron_core (>= 0.2.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
+
addressable (2.2.8)
|
10
11
|
beanstalk-client (1.1.1)
|
12
|
+
concur (0.1.2)
|
13
|
+
em-http-request
|
14
|
+
em-http-request
|
15
|
+
eventmachine
|
16
|
+
eventmachine
|
17
|
+
faraday
|
18
|
+
faraday
|
19
|
+
cookiejar (0.3.0)
|
20
|
+
em-http-request (1.0.2)
|
21
|
+
addressable (>= 2.2.3)
|
22
|
+
cookiejar
|
23
|
+
em-socksify
|
24
|
+
eventmachine (>= 1.0.0.beta.4)
|
25
|
+
http_parser.rb (>= 0.5.3)
|
26
|
+
em-socksify (0.2.0)
|
27
|
+
eventmachine (>= 1.0.0.beta.4)
|
28
|
+
eventmachine (1.0.0.rc.4)
|
29
|
+
faraday (0.8.1)
|
30
|
+
multipart-post (~> 1.1)
|
11
31
|
ffi (1.0.11)
|
12
|
-
|
13
|
-
|
14
|
-
rest
|
15
|
-
rest-client
|
32
|
+
http_parser.rb (0.5.3)
|
33
|
+
iron_core (0.2.0)
|
34
|
+
rest (>= 2.0.0)
|
16
35
|
mime-types (1.19)
|
36
|
+
multipart-post (1.1.5)
|
37
|
+
net-http-persistent (2.7)
|
17
38
|
rake (0.9.2.2)
|
18
|
-
rest (
|
39
|
+
rest (2.0.0)
|
40
|
+
net-http-persistent
|
19
41
|
rest-client (>= 0.3.0)
|
20
42
|
rest-client (1.6.7)
|
21
43
|
mime-types (>= 1.16)
|
22
|
-
test-unit (2.5.
|
44
|
+
test-unit (2.5.1)
|
23
45
|
typhoeus (0.4.2)
|
24
46
|
ffi (~> 1.0)
|
25
47
|
mime-types (~> 1.18)
|
@@ -30,7 +52,9 @@ PLATFORMS
|
|
30
52
|
|
31
53
|
DEPENDENCIES
|
32
54
|
beanstalk-client
|
55
|
+
concur
|
33
56
|
iron_mq!
|
57
|
+
net-http-persistent
|
34
58
|
rake
|
35
59
|
test-unit
|
36
60
|
typhoeus
|
data/iron_mq.gemspec
CHANGED
@@ -16,14 +16,15 @@ Gem::Specification.new do |gem|
|
|
16
16
|
|
17
17
|
gem.required_rubygems_version = ">= 1.3.6"
|
18
18
|
gem.required_ruby_version = Gem::Requirement.new(">= 1.9")
|
19
|
-
gem.add_runtime_dependency "iron_core", ">= 0.
|
19
|
+
gem.add_runtime_dependency "iron_core", ">= 0.2.0"
|
20
20
|
|
21
21
|
gem.add_development_dependency "test-unit"
|
22
22
|
gem.add_development_dependency "rake"
|
23
23
|
gem.add_development_dependency "beanstalk-client"
|
24
24
|
gem.add_development_dependency "uber_config"
|
25
25
|
gem.add_development_dependency "typhoeus"
|
26
|
-
|
26
|
+
gem.add_development_dependency "concur"
|
27
|
+
gem.add_development_dependency "net-http-persistent"
|
27
28
|
|
28
29
|
end
|
29
30
|
|
data/lib/iron_mq/client.rb
CHANGED
@@ -10,20 +10,31 @@ module IronMQ
|
|
10
10
|
attr_accessor :queue_name, :logger
|
11
11
|
|
12
12
|
def initialize(options={})
|
13
|
-
|
13
|
+
default_options = {
|
14
|
+
:scheme => 'https',
|
15
|
+
:host => IronMQ::Client::AWS_US_EAST_HOST,
|
16
|
+
:port => 443,
|
17
|
+
:api_version => 1,
|
18
|
+
:user_agent => 'iron_mq_ruby-' + IronMQ::VERSION + ' (iron_core_ruby-' + IronCore.version + ')',
|
19
|
+
:queue_name => 'default'
|
20
|
+
}
|
21
|
+
|
22
|
+
super('iron', 'mq', options, default_options, [:project_id, :token, :api_version, :queue_name])
|
23
|
+
|
24
|
+
IronCore::Logger.error 'IronMQ', "Token is not set", IronCore::Error if @token.nil?
|
25
|
+
|
26
|
+
check_id(@project_id, 'project_id')
|
14
27
|
|
15
28
|
@logger = Logger.new(STDOUT)
|
16
29
|
@logger.level = Logger::INFO
|
30
|
+
end
|
17
31
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
:queue_name => 'default'})
|
32
|
+
def headers
|
33
|
+
super.merge({'Authorization' => "OAuth #{@token}"})
|
34
|
+
end
|
22
35
|
|
23
|
-
|
24
|
-
|
25
|
-
raise IronCore::IronError.new('Both token and project_id must be specified')
|
26
|
-
end
|
36
|
+
def url
|
37
|
+
super + @api_version.to_s + '/'
|
27
38
|
end
|
28
39
|
|
29
40
|
def queue(name)
|
data/lib/iron_mq/version.rb
CHANGED
data/lib/iron_mq.rb
CHANGED
data/test/long_run.rb
CHANGED
@@ -9,18 +9,18 @@ end
|
|
9
9
|
|
10
10
|
require_relative 'long_run_worker'
|
11
11
|
|
12
|
-
@config = YAML::load_file(File.expand_path(File.join("~", "Dropbox", "configs", "iron_mq_ruby", "
|
13
|
-
@num_to_add =
|
12
|
+
@config = YAML::load_file(File.expand_path(File.join("~", "Dropbox", "configs", "iron_mq_ruby", "config.yml")))
|
13
|
+
@num_to_add = 1000
|
14
14
|
|
15
|
-
IronWorker.configure do |c|
|
16
|
-
c.token = @config['iron_mq']['token']
|
17
|
-
c.project_id = @config['iron_mq']['project_id']
|
18
|
-
end
|
15
|
+
#IronWorker.configure do |c|
|
16
|
+
# c.token = @config['iron_mq']['token']
|
17
|
+
# c.project_id = @config['iron_mq']['project_id']
|
18
|
+
#end
|
19
19
|
|
20
20
|
worker = LongRunWorker.new
|
21
21
|
worker.config = @config
|
22
22
|
worker.num_to_add = @num_to_add
|
23
|
-
worker.
|
23
|
+
worker.run
|
24
24
|
#worker.queue
|
25
25
|
#status = worker.wait_until_complete
|
26
26
|
#p status
|
data/test/long_run_worker.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
require '
|
1
|
+
require 'concur'
|
2
|
+
require 'iron_mq'
|
2
3
|
|
3
|
-
class LongRunWorker
|
4
|
-
|
5
|
-
merge_gem 'concur'
|
6
|
-
merge_gem 'iron_mq'
|
4
|
+
class LongRunWorker
|
7
5
|
|
8
6
|
attr_accessor :config, :num_to_add
|
9
7
|
|
10
8
|
def run
|
11
9
|
|
12
|
-
@client = IronMQ::Client.new(@config['
|
10
|
+
@client = IronMQ::Client.new(@config['iron'])
|
13
11
|
@client.queue_name = 'ironmq-gem-long'
|
14
12
|
|
13
|
+
@error_count = 0
|
14
|
+
|
15
15
|
start = Time.now
|
16
16
|
puts "Queuing #{@num_to_add} items at #{start}..."
|
17
17
|
executor = Concur::Executor.new_thread_pool_executor(50)
|
@@ -22,6 +22,7 @@ class LongRunWorker < IronWorker::Base
|
|
22
22
|
res = @client.messages.post("hello world! #{i}")
|
23
23
|
rescue => ex
|
24
24
|
puts "ERROR! #{ex.class.name}: #{ex.message} -- #{ex.backtrace.inspect}"
|
25
|
+
@error_count += 1
|
25
26
|
raise ex
|
26
27
|
end
|
27
28
|
end
|
@@ -53,6 +54,7 @@ class LongRunWorker < IronWorker::Base
|
|
53
54
|
|
54
55
|
puts "Finished pushing #{@num_to_add} items in #{put_time} seconds."
|
55
56
|
puts "Finished getting and deleting #{@num_to_add} items in #{(Time.now.to_f - start.to_f)} seconds."
|
57
|
+
puts "Errors: #{@error_count}"
|
56
58
|
|
57
59
|
executor.shutdown
|
58
60
|
|
data/test/test_base.rb
CHANGED
@@ -34,5 +34,11 @@ class TestBase < Test::Unit::TestCase
|
|
34
34
|
puts 'cleared.'
|
35
35
|
end
|
36
36
|
|
37
|
+
def assert_performance(time)
|
38
|
+
start_time = Time.now
|
39
|
+
yield
|
40
|
+
execution_time = Time.now - start_time
|
41
|
+
assert execution_time < time, "Execution time too big #{execution_time.round(2)}, should be #{time}"
|
42
|
+
end
|
37
43
|
|
38
44
|
end
|
data/test/test_bulk.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative 'test_base'
|
2
|
+
|
3
|
+
class TestBulk < TestBase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_bulk
|
11
|
+
|
12
|
+
q_name = 'ironmq-gem-bulk'
|
13
|
+
queue = @client.queue(q_name)
|
14
|
+
|
15
|
+
times = 50
|
16
|
+
t = Time.now
|
17
|
+
times.times do |i|
|
18
|
+
puts "Posting #{i}"
|
19
|
+
res = queue.post("hello world #{i}!")
|
20
|
+
end
|
21
|
+
puts "#{times} posts took #{Time.now.to_f - t.to_f}"
|
22
|
+
|
23
|
+
t = Time.now
|
24
|
+
res = nil
|
25
|
+
while (res = queue.get())
|
26
|
+
del = res.delete
|
27
|
+
end
|
28
|
+
puts "#{times} gets and deletes took #{Time.now.to_f - t.to_f}"
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
data/test/test_iron_mq.rb
CHANGED
@@ -20,15 +20,15 @@ class IronMQTests < TestBase
|
|
20
20
|
|
21
21
|
def test_performance_post_100_messages
|
22
22
|
@client.queue_name = 'test_basics'
|
23
|
-
|
24
|
-
|
23
|
+
# slower to rackspace since this is running on aws
|
24
|
+
timeout = @client.host.include?('rackspace') ? 40 : 10
|
25
|
+
assert_performance timeout do
|
26
|
+
100.times do
|
27
|
+
@client.messages.post("hello world!")
|
28
|
+
end
|
25
29
|
end
|
26
30
|
end
|
27
|
-
|
28
|
-
def test_performance_post_message
|
29
|
-
@client.queue_name = 'test_basics'
|
30
|
-
@client.messages.post("hello world!")
|
31
|
-
end
|
31
|
+
|
32
32
|
|
33
33
|
def test_basics
|
34
34
|
@client.queue_name = 'test_basics'
|
@@ -163,7 +163,7 @@ class IronMQTests < TestBase
|
|
163
163
|
def test_queues
|
164
164
|
puts 'test_queues'
|
165
165
|
|
166
|
-
assert_raise
|
166
|
+
assert_raise Rest::HttpError do
|
167
167
|
# should raise a 404
|
168
168
|
q = @client.queues.get(:name => "some_queue_that_does_not_exist")
|
169
169
|
end
|
@@ -177,7 +177,7 @@ class IronMQTests < TestBase
|
|
177
177
|
end
|
178
178
|
assert res.size > 0
|
179
179
|
|
180
|
-
res = @client.queues.list(:page =>
|
180
|
+
res = @client.queues.list(:page => 15)
|
181
181
|
puts "res.size 2: " + res.size.to_s
|
182
182
|
res.each do |q|
|
183
183
|
p q.name
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_mq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: iron_core
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.2.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: test-unit
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,6 +107,38 @@ dependencies:
|
|
107
107
|
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: concur
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: net-http-persistent
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
110
142
|
description: Ruby client for IronMQ by www.iron.io
|
111
143
|
email:
|
112
144
|
- treeder@gmail.com
|
@@ -125,16 +157,14 @@ files:
|
|
125
157
|
- lib/iron_mq/messages.rb
|
126
158
|
- lib/iron_mq/queues.rb
|
127
159
|
- lib/iron_mq/version.rb
|
128
|
-
- test/Gemfile
|
129
|
-
- test/Gemfile.lock
|
130
160
|
- test/long_run.rb
|
131
161
|
- test/long_run_worker.rb
|
132
162
|
- test/quick_run.rb
|
133
163
|
- test/schedule_abt.rb
|
134
164
|
- test/test_base.rb
|
135
165
|
- test/test_beanstalkd.rb
|
166
|
+
- test/test_bulk.rb
|
136
167
|
- test/test_iron_mq.rb
|
137
|
-
- test/test_push_queues.rb
|
138
168
|
homepage: https://github.com/iron-io/iron_mq_ruby
|
139
169
|
licenses: []
|
140
170
|
post_install_message:
|
@@ -160,13 +190,11 @@ signing_key:
|
|
160
190
|
specification_version: 3
|
161
191
|
summary: Ruby client for IronMQ by www.iron.io
|
162
192
|
test_files:
|
163
|
-
- test/Gemfile
|
164
|
-
- test/Gemfile.lock
|
165
193
|
- test/long_run.rb
|
166
194
|
- test/long_run_worker.rb
|
167
195
|
- test/quick_run.rb
|
168
196
|
- test/schedule_abt.rb
|
169
197
|
- test/test_base.rb
|
170
198
|
- test/test_beanstalkd.rb
|
199
|
+
- test/test_bulk.rb
|
171
200
|
- test/test_iron_mq.rb
|
172
|
-
- test/test_push_queues.rb
|
data/test/Gemfile
DELETED
data/test/Gemfile.lock
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
addressable (2.2.8)
|
5
|
-
beanstalk-client (1.1.1)
|
6
|
-
concur (0.1.2)
|
7
|
-
em-http-request
|
8
|
-
em-http-request
|
9
|
-
eventmachine
|
10
|
-
eventmachine
|
11
|
-
faraday
|
12
|
-
faraday
|
13
|
-
cookiejar (0.3.0)
|
14
|
-
em-http-request (1.0.2)
|
15
|
-
addressable (>= 2.2.3)
|
16
|
-
cookiejar
|
17
|
-
em-socksify
|
18
|
-
eventmachine (>= 1.0.0.beta.4)
|
19
|
-
http_parser.rb (>= 0.5.3)
|
20
|
-
em-socksify (0.2.0)
|
21
|
-
eventmachine (>= 1.0.0.beta.4)
|
22
|
-
eventmachine (1.0.0.beta.4)
|
23
|
-
faraday (0.8.1)
|
24
|
-
multipart-post (~> 1.1)
|
25
|
-
http_parser.rb (0.5.3)
|
26
|
-
iron_core (0.1.4)
|
27
|
-
bundler (> 1.0.0)
|
28
|
-
rest
|
29
|
-
rest-client
|
30
|
-
mime-types (1.18)
|
31
|
-
multipart-post (1.1.5)
|
32
|
-
rest (0.3.0)
|
33
|
-
rest-client
|
34
|
-
rest-client
|
35
|
-
rest-client (1.6.7)
|
36
|
-
mime-types (>= 1.16)
|
37
|
-
test-unit (2.5.0)
|
38
|
-
uber_config (0.0.3)
|
39
|
-
|
40
|
-
PLATFORMS
|
41
|
-
ruby
|
42
|
-
|
43
|
-
DEPENDENCIES
|
44
|
-
beanstalk-client
|
45
|
-
concur
|
46
|
-
iron_core
|
47
|
-
test-unit
|
48
|
-
uber_config
|
data/test/test_push_queues.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# Put config.yml file in ~/Dropbox/configs/ironmq_gem/test/config.yml
|
2
|
-
require_relative 'test_base'
|
3
|
-
|
4
|
-
class TestPushQueues < TestBase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
super
|
8
|
-
@client.queue_name = 'ironmq-gem-quick'
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_message_subscriptions
|
12
|
-
res = @client.messages.post("hello world!", :subscriptions=>["http://requestb.in/oui4adou"])
|
13
|
-
assert res.id
|
14
|
-
post_id = res.id
|
15
|
-
assert res.msg
|
16
|
-
p res
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_queue_subscriptions
|
20
|
-
qname = "subscription-queue"
|
21
|
-
res = @client.queues.post(:queue_name=>qname, :subscriptions=>["http://requestb.in/1lhkwk31", "http://requestb.in/1icckwe1"])
|
22
|
-
q = @client.queues.get(:queue_name=>qname)
|
23
|
-
p q
|
24
|
-
p q["subscriptions"]
|
25
|
-
|
26
|
-
@client.messages.post("hello sub queue", :queue_name=>qname)
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|