rservicebus2 0.2.13 → 0.2.14

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
  SHA256:
3
- metadata.gz: 51c1a3dd6e3b22da8216ba061cb1572a5dd29475353c0b10ea470bdda7d7e3f7
4
- data.tar.gz: 3952dfc273048ca7cecd3dca0179891d8d9bcc341e137b3212ce611c10523681
3
+ metadata.gz: cb17f3e3c5855d25725fd906122c5880299c33ef25a585d445b1ca63eb3b0a79
4
+ data.tar.gz: b950f8c099a79b02837dc6c1382ae4f36eb20d6b35f9c7e06f3351ac11804803
5
5
  SHA512:
6
- metadata.gz: 0ed0ba711726a1641c1c3fab6811843f826633caca5c3061d5d223731313cc0138f182842768bece201041001a081ba899261bbbde5a0415fdeadd4252127ef5
7
- data.tar.gz: 3976c2ec0eb733817f5b364bd0ee788a9ce1d13c2ff48c08694c5df916441d38ba6bbbfa6f0e8822a1143f51a00b53fd037ef9194a5e1fde969c8f75b0672aa4
6
+ metadata.gz: ebb2ef88679f5827b905fc50f604c41dacbaaecbf5878181c0ce46801d9cb24d8df060ef4c39ef37f6bfd130a7dc5c0724f135d3905941841ba0470eaee4eb4f
7
+ data.tar.gz: 57c5279177ead71990a756c142f5ac17b2306116e359d4e7edcad448180ad5523c3f8132e024dfbf034b7cb30c8e790788990c00c01a825650eacadc981b1cbc
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'beanstalk-client'
4
+ require 'cgi'
5
+
6
+ module RServiceBus2
7
+ # Monitor S3 Bucket for objects
8
+ class MonitorBeanstalk < Monitor
9
+ def deduce_timeout(uri)
10
+ return 5 if uri.query.nil?
11
+
12
+ CGI.parse(u.query)['timeout1']&.first || 5
13
+ end
14
+
15
+ # rubocop:disable Metrics/MethodLength
16
+ def connect(uri)
17
+ @uri = uri
18
+ @timeout = deduce_timeout(uri)
19
+
20
+ queue_name = uri.path.sub('/', '')
21
+
22
+ port ||= 11_300
23
+ connection_string = "#{uri.host}:#{port}"
24
+ @beanstalk = Beanstalk::Pool.new([connection_string])
25
+
26
+ @beanstalk.watch(queue_name)
27
+ @message_uri = "beanstalk://#{uri.host}:#{port}/#{queue_name}"
28
+ rescue StandardError => e
29
+ puts "Error connecting to Beanstalk, Host string, #{connection_string}"
30
+ if e.message == 'Beanstalk::NotConnected'
31
+ puts '***Most likely, beanstalk is not running. Start beanstalk, and try running this again.\n' \
32
+ "***If you still get this error, check beanstalk is running at, #{connection_string}"
33
+ abort
34
+ end
35
+
36
+ puts e.message
37
+ puts e.backtrace
38
+ end
39
+ # rubocop:enable Metrics/MethodLength
40
+
41
+ def look
42
+ job = @beanstalk.reserve @timeout
43
+ send(job.body, "#{@message_uri}/#{job.id}")
44
+ job_body = job.body
45
+ job.delete
46
+ job_body
47
+ rescue StandardError => e
48
+ return if e.message == 'TIMED_OUT'
49
+
50
+ raise e
51
+ end
52
+ end
53
+ end
@@ -57,6 +57,9 @@ module RServiceBus2
57
57
  when 'dirnotifier'
58
58
  require 'rservicebus2/monitor/dirnotifier'
59
59
  monitor = MonitorDirNotifier.new(@host, name, uri)
60
+ when 'beanstalk'
61
+ require 'rservicebus2/monitor/beanstalk'
62
+ monitor = MonitorBeanstalk.new(@host, name, uri)
60
63
  else
61
64
  abort("Scheme, #{uri.scheme}, not recognised when configuring
62
65
  Monitor, #{key}=#{val}")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rservicebus2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.13
4
+ version: 0.2.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guy Irvine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-13 00:00:00.000000000 Z
11
+ date: 2021-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: beanstalk-client
@@ -129,6 +129,7 @@ files:
129
129
  - lib/rservicebus2/monitor.rb
130
130
  - lib/rservicebus2/monitor/awss3.rb
131
131
  - lib/rservicebus2/monitor/awssqs.rb
132
+ - lib/rservicebus2/monitor/beanstalk.rb
132
133
  - lib/rservicebus2/monitor/dir.rb
133
134
  - lib/rservicebus2/monitor/dirnotifier.rb
134
135
  - lib/rservicebus2/monitor/message.rb