rservicebus2 0.2.0 → 0.2.3

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
- SHA1:
3
- metadata.gz: e7e4478dcfd17cf33e195c10a8e26aa9394e6b0f
4
- data.tar.gz: 5f712faee16f86b3ed2f56289ffced68781e5c94
2
+ SHA256:
3
+ metadata.gz: 3e12a4225a0bdda2fdc600e0f5f1134dacf481343d7e9e3e3837b820ca1f8509
4
+ data.tar.gz: 02e285f84043c7f457db328a9fd74c1f7f62104531cae5b723ba301aca518a3f
5
5
  SHA512:
6
- metadata.gz: c730bfeb3dd50ceb5dc8aab7f2fcc7663c2539229fcf12a87c6da81855b8d3d626104710a83a01b13a09bca2e3d042f8f125e8f12d2bbe17738b15c3d7ef9b43
7
- data.tar.gz: aeb9173b91dfeaeefa82a67fba42dbcf9401ad20d7560e559e7b12e271e391d9e2474805f1a860c2845aa2416006ad7b8f0c4f15f9dd2c42dc56069b08fc63f1
6
+ metadata.gz: a2aefd96d740b7020284d95f36256fead951f895fab13e8eeb1440b674ebdb28a580a11ad75c4cbb1dbb270b1aef0ed901af1b94d03459252cfe33947b85aac1
7
+ data.tar.gz: 848e86f7d3c40f83cdb1f6d3459af1a5265f1e9272c7718da950c81457ff54983c0d00bc3997b0b0955df57798a53ff7be3650463458cdbe2b926c636053ddde
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # rservicebus2
2
+
3
+ Use the examples directory as the starting point.
4
+
5
+ ## General Approach
6
+
7
+ 1. Convention over Configuration
8
+ 2. Configuration via Environment Variables
9
+ 3. Working examples provided for configuration
10
+
11
+ ## General Config
12
+
13
+ ### APPNAME
14
+ 1. Name of process
15
+ 2. Doubles as default queueName
16
+ 3. Defaults to directory name
17
+
18
+ ### MAX_RETRIES
19
+ 1. If an exception is generated while processing a message, the message can be
20
+ retried. This allows the number of retries to be set.
21
+ 2. Defaults to 5
22
+
23
+ ### ERROR_QUEUE_NAME
24
+ 1. If an exception is generated while processing a message, the message can be
25
+ retried. Once all retries are exhausted, the message will be put in the error queue.
26
+ 2. This allows the name of the queue to be set.
27
+ 3. Defaults to error
28
+
29
+ ### WORKING_DIR
30
+ 1. Where message handlers are looked for.
31
+ 2. Defaults to current directory
32
+
33
+ ### VERBOSE
34
+ 1. Send out more logging to track message processing
35
+
36
+ ### AUDIT_QUEUE_NAME
37
+ 1. When set, a copy of all messages sent and received will be add to this queue
38
+
39
+ ### RSBCRON_[msg name]
40
+ 1. An empty message will be created and sent based on the cron string
41
+
42
+ ## RSBMQ - Message queue
43
+ 1. Environment Variable Name: RSBMQ
44
+
45
+ ### Beanstalk
46
+
47
+ ### Redis
48
+
49
+ ### SQS
50
+ RSBMQ=aws://[region]/[queue_name]
@@ -20,10 +20,13 @@ module RServiceBus2
20
20
  mq = MQBeanstalk.new(uri)
21
21
  when 'file'
22
22
  require 'rservicebus2/mq/file'
23
- mq = MQFile.new(uri)
23
+ mq = MQFile.new(uri)
24
24
  when 'redis'
25
25
  require 'rservicebus2/mq/redis'
26
- mq = MQRedis.new(uri)
26
+ mq = MQRedis.new(uri)
27
+ when 'aws'
28
+ require 'rservicebus2/mq/aws'
29
+ mq = MQAWS.new(uri)
27
30
  else
28
31
  abort("Scheme, #{uri.scheme}, not recognised when configuring mq,
29
32
  #{string}")
@@ -0,0 +1,85 @@
1
+ require 'aws-sdk-sqs'
2
+ require 'aws-sdk-sts'
3
+ require 'rservicebus2/mq'
4
+
5
+ module RServiceBus2
6
+ # Beanstalk client implementation.
7
+ class MQAWS < MQ
8
+ # Connect to the broker
9
+ # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
10
+ def connect(region, port)
11
+ begin
12
+ @max_job_size = 4_194_304
13
+ @region = region
14
+
15
+ sts_client = Aws::STS::Client.new(region: region)
16
+ @caller_identity_account = sts_client.get_caller_identity.account
17
+ rescue StandardError => e
18
+ puts 'Error connecting to AWS'
19
+ puts "Host string, #{region}"
20
+ puts e.message
21
+ puts e.backtrace
22
+ abort
23
+ end
24
+ end
25
+
26
+ def subscribe(queuename)
27
+ # For example:
28
+ # 'https://sqs.us-east-1.amazonaws.com/111111111111/my-queue'
29
+ @queue_url = 'https://sqs.' + @region + '.amazonaws.com/' +
30
+ @caller_identity_account + '/' + queuename
31
+ @sqs_client = Aws::SQS::Client.new(region: @region)
32
+ end
33
+
34
+ # Get next msg from queue
35
+ def pop
36
+ begin
37
+ response = @sqs_client.receive_message(
38
+ queue_url: @queue_url,
39
+ max_number_of_messages: 1
40
+ )
41
+
42
+ if response.messages.count.zero?
43
+ raise NoMsgToProcess
44
+ end
45
+
46
+ response.messages.each do |message|
47
+ @job = message
48
+ end
49
+ rescue StandardError => e
50
+ raise e
51
+ end
52
+ @job.body
53
+ end
54
+
55
+ def return_to_queue
56
+ # @job.release if @job
57
+ @job = nil
58
+ end
59
+
60
+ def ack
61
+ @sqs_client.delete_message({
62
+ queue_url: @queue_url,
63
+ receipt_handle: @job.receipt_handle
64
+ })
65
+ @job = nil
66
+ end
67
+
68
+ def send(queue_name, msg)
69
+ if msg.length > @max_job_size
70
+ puts '***Attempting to send a msg which will not fit on queue.'
71
+ puts "***Msg size, #{msg.length}, max msg size, #{@max_job_size}."
72
+ fail JobTooBigError, "Msg size, #{msg.length}, max msg size,
73
+ #{@max_job_size}"
74
+ end
75
+
76
+ queue_url = 'https://sqs.' + @region + '.amazonaws.com/' +
77
+ @caller_identity_account + '/' + queue_name
78
+
79
+ @sqs_client.send_message(
80
+ queue_url: queue_url,
81
+ message_body: msg
82
+ )
83
+ end
84
+ end
85
+ end
metadata CHANGED
@@ -1,85 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rservicebus2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guy Irvine
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-28 00:00:00.000000000 Z
11
+ date: 2021-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uuidtools
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 2.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 2.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 2.5.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 2.5.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: beanstalk-client
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 1.1.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 1.1.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: fluiddb
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.1.19
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 0.1.19
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: parse-cron
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 0.1.4
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: 0.1.4
83
83
  description: A Ruby interpretation of NServiceBus
84
84
  email: guy@guyirvine.com
85
85
  executables:
@@ -93,6 +93,7 @@ extensions: []
93
93
  extra_rdoc_files: []
94
94
  files:
95
95
  - LICENSE
96
+ - README.md
96
97
  - bin/return_messages_to_source_queue
97
98
  - bin/rsb_ctl
98
99
  - bin/rservicebus2
@@ -129,6 +130,7 @@ files:
129
130
  - lib/rservicebus2/monitor/xmldir.rb
130
131
  - lib/rservicebus2/monitor_configure.rb
131
132
  - lib/rservicebus2/mq.rb
133
+ - lib/rservicebus2/mq/aws.rb
132
134
  - lib/rservicebus2/mq/beanstalk.rb
133
135
  - lib/rservicebus2/mq/file.rb
134
136
  - lib/rservicebus2/mq/redis.rb
@@ -162,7 +164,7 @@ homepage: http://rubygems.org/gems/rservicebus2
162
164
  licenses:
163
165
  - LGPL-3.0
164
166
  metadata: {}
165
- post_install_message:
167
+ post_install_message:
166
168
  rdoc_options: []
167
169
  require_paths:
168
170
  - lib
@@ -177,9 +179,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
179
  - !ruby/object:Gem::Version
178
180
  version: '0'
179
181
  requirements: []
180
- rubyforge_project:
181
- rubygems_version: 2.5.2.1
182
- signing_key:
182
+ rubygems_version: 3.0.9
183
+ signing_key:
183
184
  specification_version: 4
184
185
  summary: RServiceBus
185
186
  test_files: []