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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c20d8a34264145fc0f492c81cb8981042334f0d
4
- data.tar.gz: c1b5e70c54069938537d663f0ca90d630611beb0
3
+ metadata.gz: fada1aee3a7884d50bf77a55981556c5b813ddcf
4
+ data.tar.gz: dd63dae7e3e5dcac2d0fc9d316202edb38eab16a
5
5
  SHA512:
6
- metadata.gz: abd57f30d3ec6f0bb29edefb353939e8fb186931ccbdde24e5d05469842cf7e4bd95c79a434698dd9a5eb2442493fa43f8a2d7f6fe2d09c753e5240e288f65eb
7
- data.tar.gz: e1eeba5be8ba48df45110188b51d6b66d5f44e8c361c9189007bfb39853e5c8c1b12e76f1f631fd03cb658b36c038b76b27a9fdfd2f6b4280d915a4317450b65
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
@@ -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.3
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