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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ea0b8dd06a2280f3ca70bef921b34f4bad2c1d6a4c043a6accb119b83566940
4
- data.tar.gz: b7607e7ed6a0fe7fbe935aa5b3cc2d27817973b33f96c5dda58d0651a1f17570
3
+ metadata.gz: c1e12570efafa3e17329ee11b4f458e86ba6d61700dea27f5552e3ef54945cd4
4
+ data.tar.gz: 0ad1c7926d644e24f795d6baaacba9b18bbb60c51c6f8d2018b7829c2f02433a
5
5
  SHA512:
6
- metadata.gz: 1963af8198779b9efabe33b85c236205fcdababb5a75e5b551d72073b9e4342818ac13878e2f533f295ca2e0a90be2767da641230d8382b15d4d485566fc9ac5
7
- data.tar.gz: 06dc10763f2a56066405abbe7dff686d120d755f26d3ce8a3b6ca43152c31c8ca2f8826a51ec4fdb3a3d5bb836c4890770919b9cdd9ce603fb94eb4a710dbb0c
6
+ metadata.gz: 2db9257198bff90b072fc80f1561e18373b831064f321e3d3238a37904a1026a506276f64d51eb575d21d9d7a5f58d5be4c27246e6e49608b569eb722f7e70fc
7
+ data.tar.gz: 88f37e1a0d0837baf786ad2dfaf685f4bce862f62eebeca837275e06d37954a4681f0549b54b6e10757d9cce38a4fc1c99e68c58bb59c88be009584c1c0865cc
@@ -7,9 +7,7 @@ module RServiceBus2
7
7
  def connect(uri)
8
8
  region = uri.host
9
9
 
10
- aws = Aws::DynamoDB::Client.new(region: region)
11
- puts "aws #{aws}"
12
- aws
10
+ Aws::DynamoDB::Client.new(region: region)
13
11
  end
14
12
 
15
13
  def finished
@@ -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}")
@@ -26,6 +26,7 @@ module RServiceBus2
26
26
  def initialize(bus, name, uri)
27
27
  @bus = bus
28
28
  new_anonymous_class = Class.new(MonitorMessage)
29
+ puts "name: #{name}"
29
30
  Object.const_set(name, new_anonymous_class)
30
31
  @msg_type = Object.const_get(name)
31
32
 
@@ -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
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