rservicebus2 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rservicebus2/mq/redis.rb +53 -0
- data/lib/rservicebus2/mq.rb +3 -0
- 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: fada1aee3a7884d50bf77a55981556c5b813ddcf
|
4
|
+
data.tar.gz: dd63dae7e3e5dcac2d0fc9d316202edb38eab16a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0bfe746cdd9d90688a6dbea40589db4c9fdd99054fd38406eaaa87f46756d969422d6ca5d404622c7989638385ca0c6aff37fb34e95b02ce84caa4f689f193e
|
7
|
+
data.tar.gz: c7f3ea7b8960d47ce837cffb3d085c64665cd0c053b531ccd7baecc146720597ca261a05166ccec26e2e74f6d92fea7d34506d3a8fe6d58b8cfc5be3f36d074b
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'redis'
|
2
|
+
require 'rservicebus2/mq'
|
3
|
+
|
4
|
+
module RServiceBus2
|
5
|
+
# Redis client implementation.
|
6
|
+
class MQRedis < MQ
|
7
|
+
# Connect to the broker
|
8
|
+
# rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
9
|
+
def connect(host, port)
|
10
|
+
port ||= 6379
|
11
|
+
string = "#{host}:#{port}"
|
12
|
+
|
13
|
+
begin
|
14
|
+
@redis = Redis.new(:host => host, :port => port)
|
15
|
+
|
16
|
+
rescue Exception => e
|
17
|
+
puts e.message
|
18
|
+
puts 'Error connecting to Redis for mq'
|
19
|
+
puts "Host string, #{string}"
|
20
|
+
abort()
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Connect to the queue
|
25
|
+
def subscribe( queuename )
|
26
|
+
@queuename = queuename
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get next msg from queue
|
30
|
+
def pop
|
31
|
+
if @redis.llen( @queuename ) == 0 then
|
32
|
+
sleep @timeout
|
33
|
+
raise NoMsgToProcess.new
|
34
|
+
end
|
35
|
+
|
36
|
+
return @redis.lindex @queuename, 0
|
37
|
+
end
|
38
|
+
|
39
|
+
def returnToQueue
|
40
|
+
end
|
41
|
+
|
42
|
+
# "Commit" queue
|
43
|
+
def ack
|
44
|
+
@redis.lpop @queuename
|
45
|
+
end
|
46
|
+
|
47
|
+
# At least called in the Host rescue block, to ensure all network links are healthy
|
48
|
+
def send( queueName, msg )
|
49
|
+
@redis.rpush queueName, msg
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
data/lib/rservicebus2/mq.rb
CHANGED
@@ -21,6 +21,9 @@ module RServiceBus2
|
|
21
21
|
when 'file'
|
22
22
|
require 'rservicebus2/mq/file'
|
23
23
|
mq = MQFile.new(uri)
|
24
|
+
when 'redis'
|
25
|
+
require 'rservicebus2/mq/redis'
|
26
|
+
mq = MQRedis.new(uri)
|
24
27
|
else
|
25
28
|
abort("Scheme, #{uri.scheme}, not recognised when configuring mq,
|
26
29
|
#{string}")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rservicebus2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guy Irvine
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/rservicebus2/mq.rb
|
132
132
|
- lib/rservicebus2/mq/beanstalk.rb
|
133
133
|
- lib/rservicebus2/mq/file.rb
|
134
|
+
- lib/rservicebus2/mq/redis.rb
|
134
135
|
- lib/rservicebus2/resource_manager.rb
|
135
136
|
- lib/rservicebus2/saga/base.rb
|
136
137
|
- lib/rservicebus2/saga/data.rb
|