rservicebus2 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rservicebus2/appresource/awsdynamodb.rb +1 -3
- data/lib/rservicebus2/appresource/awss3.rb +16 -0
- data/lib/rservicebus2/appresource_configure.rb +3 -0
- data/lib/rservicebus2/monitor.rb +1 -0
- data/lib/rservicebus2/monitor/awss3.rb +73 -0
- data/lib/rservicebus2/monitor_configure.rb +3 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1e12570efafa3e17329ee11b4f458e86ba6d61700dea27f5552e3ef54945cd4
|
4
|
+
data.tar.gz: 0ad1c7926d644e24f795d6baaacba9b18bbb60c51c6f8d2018b7829c2f02433a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2db9257198bff90b072fc80f1561e18373b831064f321e3d3238a37904a1026a506276f64d51eb575d21d9d7a5f58d5be4c27246e6e49608b569eb722f7e70fc
|
7
|
+
data.tar.gz: 88f37e1a0d0837baf786ad2dfaf685f4bce862f62eebeca837275e06d37954a4681f0549b54b6e10757d9cce38a4fc1c99e68c58bb59c88be009584c1c0865cc
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'aws-sdk-s3'
|
2
|
+
|
3
|
+
module RServiceBus2
|
4
|
+
# AppResourceAWSDynamoDb
|
5
|
+
class AppResourceAWSS3 < AppResource
|
6
|
+
# rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
7
|
+
def connect(uri)
|
8
|
+
region = uri.host
|
9
|
+
|
10
|
+
Aws::S3::Client.new(region: region)
|
11
|
+
end
|
12
|
+
|
13
|
+
def finished
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -34,6 +34,9 @@ module RServiceBus2
|
|
34
34
|
when 'awsdynamodb'
|
35
35
|
require 'rservicebus2/appresource/awsdynamodb'
|
36
36
|
rm.add k.sub('RSB_', ''), AppResourceAWSDynamoDb.new(host, uri)
|
37
|
+
when 'awss3'
|
38
|
+
require 'rservicebus2/appresource/awss3'
|
39
|
+
rm.add k.sub('RSB_', ''), AppResourceAWSS3.new(host, uri)
|
37
40
|
else
|
38
41
|
abort("Scheme, #{uri.scheme}, not recognised when configuring
|
39
42
|
app resource, #{k}=#{v}")
|
data/lib/rservicebus2/monitor.rb
CHANGED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'aws-sdk-s3'
|
2
|
+
|
3
|
+
module RServiceBus2
|
4
|
+
# Monitor S3 Bucket for objects
|
5
|
+
class MonitorAWSS3 < Monitor
|
6
|
+
def connect(uri)
|
7
|
+
@bucket_name = uri.path
|
8
|
+
@bucket_name[0] = ''
|
9
|
+
|
10
|
+
@region = uri.host
|
11
|
+
|
12
|
+
@s3_client = Aws::S3::Client.new(region: @region)
|
13
|
+
@input_filter = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def process_content(content)
|
17
|
+
content
|
18
|
+
end
|
19
|
+
|
20
|
+
# rubocop:disable Metrics/MethodLength
|
21
|
+
def read_content_from_file(file_path)
|
22
|
+
content = ''
|
23
|
+
if @input_filter.length > 0
|
24
|
+
if @input_filter[0] == 'ZIP'
|
25
|
+
content = read_content_from_zip_file(file_path)
|
26
|
+
elsif @input_filter[0] == 'GZ'
|
27
|
+
content = read_content_from_gz_file(file_path)
|
28
|
+
elsif @input_filter[0] == 'TAR'
|
29
|
+
fail 'TAR reader not implemented'
|
30
|
+
end
|
31
|
+
|
32
|
+
else
|
33
|
+
content = IO.read(file_path)
|
34
|
+
end
|
35
|
+
|
36
|
+
content
|
37
|
+
end
|
38
|
+
|
39
|
+
def process_path(object_key)
|
40
|
+
# content = read_content_from_object(object_key)
|
41
|
+
content = object_key
|
42
|
+
payload = process_content(content)
|
43
|
+
|
44
|
+
send(payload, URI.parse(URI.encode("s3://#{@region}/#{@bucket_name}/#{object_key}")))
|
45
|
+
content
|
46
|
+
end
|
47
|
+
|
48
|
+
def look
|
49
|
+
file_processed = 0
|
50
|
+
max_files_processed = 1
|
51
|
+
|
52
|
+
objects = @s3_client.list_objects_v2(
|
53
|
+
bucket: @bucket_name,
|
54
|
+
max_keys: max_files_processed
|
55
|
+
).contents
|
56
|
+
|
57
|
+
return if objects.count.zero?
|
58
|
+
|
59
|
+
objects.each do |object|
|
60
|
+
RServiceBus2.log "Ready to process, #{object.key}"
|
61
|
+
process_path(object.key)
|
62
|
+
# content = process_path(object.key)
|
63
|
+
|
64
|
+
# File.unlink(file_path)
|
65
|
+
|
66
|
+
file_processed += 1
|
67
|
+
RServiceBus2.log "Processed #{file_processed} of #{objects.length}."
|
68
|
+
RServiceBus2.log "Allow system tick #{self.class.name}"
|
69
|
+
break if file_processed >= max_files_processed
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -48,6 +48,9 @@ module RServiceBus2
|
|
48
48
|
when 'dir'
|
49
49
|
require 'rservicebus2/monitor/dir'
|
50
50
|
monitor = MonitorDir.new(@host, name, uri)
|
51
|
+
when 'awss3'
|
52
|
+
require 'rservicebus2/monitor/awss3'
|
53
|
+
monitor = MonitorAWSS3.new(@host, name, uri)
|
51
54
|
when 'dirnotifier'
|
52
55
|
require 'rservicebus2/monitor/dirnotifier'
|
53
56
|
monitor = MonitorDirNotifier.new(@host, name, uri)
|
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.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guy Irvine
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- lib/rservicebus2/agent.rb
|
106
106
|
- lib/rservicebus2/appresource.rb
|
107
107
|
- lib/rservicebus2/appresource/awsdynamodb.rb
|
108
|
+
- lib/rservicebus2/appresource/awss3.rb
|
108
109
|
- lib/rservicebus2/appresource/dir.rb
|
109
110
|
- lib/rservicebus2/appresource/file.rb
|
110
111
|
- lib/rservicebus2/appresource/fluiddb.rb
|
@@ -125,6 +126,7 @@ files:
|
|
125
126
|
- lib/rservicebus2/message/subscription.rb
|
126
127
|
- lib/rservicebus2/message/verboseoutput.rb
|
127
128
|
- lib/rservicebus2/monitor.rb
|
129
|
+
- lib/rservicebus2/monitor/awss3.rb
|
128
130
|
- lib/rservicebus2/monitor/dir.rb
|
129
131
|
- lib/rservicebus2/monitor/dirnotifier.rb
|
130
132
|
- lib/rservicebus2/monitor/message.rb
|