rabbit_jobs 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rabbit_jobs/amqp_helpers.rb +2 -1
- data/lib/rabbit_jobs/configuration.rb +18 -0
- data/lib/rabbit_jobs/publisher.rb +1 -2
- data/lib/rabbit_jobs/version.rb +1 -1
- metadata +11 -11
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
+
require 'uri'
|
2
3
|
|
3
4
|
module RabbitJobs
|
4
5
|
module AmqpHelpers
|
@@ -15,7 +16,7 @@ module RabbitJobs
|
|
15
16
|
block.call(connection, exchange)
|
16
17
|
|
17
18
|
else
|
18
|
-
AMQP.start(RJ.config.
|
19
|
+
AMQP.start(RJ.config.connection_options) do |connection|
|
19
20
|
|
20
21
|
channel = AMQP::Channel.new(connection)
|
21
22
|
|
@@ -72,6 +72,23 @@ module RabbitJobs
|
|
72
72
|
@data[name]
|
73
73
|
end
|
74
74
|
|
75
|
+
def connection_options
|
76
|
+
return @data[:connection_options] if @data[:connection_options]
|
77
|
+
|
78
|
+
ports = {'amqp' => 5672, 'amqps' => 5671}
|
79
|
+
uri = URI.parse(self.url)
|
80
|
+
|
81
|
+
raise "Unknown scheme" unless ports.keys.include?(uri.scheme.downcase)
|
82
|
+
|
83
|
+
@data[:connection_options] = {
|
84
|
+
host: uri.host || 'localhost',
|
85
|
+
port: uri.port || ports[uri.scheme.downcase],
|
86
|
+
vhost: uri.path || '/',
|
87
|
+
user: uri.user || 'guest',
|
88
|
+
password: uri.password || 'guest'
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
75
92
|
def mail_errors_to(email = nil)
|
76
93
|
if email
|
77
94
|
@data[:mail_errors_to] = email
|
@@ -100,6 +117,7 @@ module RabbitJobs
|
|
100
117
|
if value
|
101
118
|
raise ArgumentError unless value.is_a?(String) && value != ""
|
102
119
|
@data[:url] = value.to_s
|
120
|
+
@data[:connection_options] = nil
|
103
121
|
else
|
104
122
|
@data[:url] || 'amqp://localhost'
|
105
123
|
end
|
@@ -60,8 +60,7 @@ module RabbitJobs
|
|
60
60
|
def self.with_bunny(&block)
|
61
61
|
raise ArgumentError unless block
|
62
62
|
|
63
|
-
|
64
|
-
Bunny.run(url: RJ.config.url, host: uri.host, logging: false) do |bunny|
|
63
|
+
Bunny.run(RJ.config.connection_options.merge({logging: false})) do |bunny|
|
65
64
|
block.call(bunny)
|
66
65
|
end
|
67
66
|
end
|
data/lib/rabbit_jobs/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabbit_jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-05-10 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: amqp
|
16
|
-
requirement: &
|
16
|
+
requirement: &70306208435960 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.9'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70306208435960
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bunny
|
27
|
-
requirement: &
|
27
|
+
requirement: &70306208435000 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0.7'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70306208435000
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70306208433540 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70306208433540
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rufus-scheduler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70306208431520 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '2.0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70306208431520
|
58
58
|
description: Background jobs on RabbitMQ
|
59
59
|
email:
|
60
60
|
- lazureykis@gmail.com
|
@@ -109,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
segments:
|
111
111
|
- 0
|
112
|
-
hash: -
|
112
|
+
hash: -1920366200643648067
|
113
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
114
|
none: false
|
115
115
|
requirements:
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
segments:
|
120
120
|
- 0
|
121
|
-
hash: -
|
121
|
+
hash: -1920366200643648067
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
124
|
rubygems_version: 1.8.15
|