stream_data 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 874fd41ff4e3a8ef0c1e1a0b2c369a8342082eb620851f0d9ce32b9dacd3d814
4
+ data.tar.gz: e551fa7f663564e12364055f7f3f42156894065073e4f583f0b01dbe68c03ad0
5
+ SHA512:
6
+ metadata.gz: d01a6f7ecd446e80304ce192314ab428ee170708339e0246ab06aa85bac83fbd4232251d350b1142f30c5bec822d5fb8255d12741f2bf202ed58c30a5d7445b7
7
+ data.tar.gz: e9c7edfcb5c3f34a0b25bcdfe89e760a30f00c5d403c445ba2e4642eb87467c0810fa4d63fa507fe7e4a0e494ffdcec696d182b35e7853912a2952fcd3a4088c
@@ -0,0 +1,39 @@
1
+ module StreamData
2
+ # require 'aws'
3
+ require 'aws-sdk'
4
+
5
+ class AwsStreamService
6
+
7
+ def initialize(config,opts)
8
+ set_connection(config,opts)
9
+ end
10
+
11
+ def send_stream(raw_data)
12
+ begin
13
+ puts "#{@config.inspect} asdasda saran"
14
+ puts "#{@config[:delivery_stream_name ]} asdasda saran"
15
+ @firehose.put_record({ delivery_stream_name: @config[:delivery_stream_name], record: { data: raw_data}})
16
+ rescue Aws::Errors::MissingCredentialsError => e
17
+ raise (StandardError.new("Error with the connection. Check the config. Error message === #{e.message}"))
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def set_connection(config,opts)
24
+ @config = config || {}
25
+ @opts = opts || {}
26
+ begin
27
+ @firehose = Aws::Firehose::Client.new(
28
+ access_key_id: config[:service_key],
29
+ secret_access_key: config[:service_secret],
30
+ region: config[:region]
31
+ )
32
+ rescue Exception => e
33
+ raise (StandardError.new("Could not establish a connection. Check the config. Error message === #{e.message}"))
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,40 @@
1
+ require 'aws_stream_service'
2
+ module StreamData
3
+ class Config
4
+
5
+ ALLOWED_SERVICE_TYPES = ["azure","aws"]
6
+
7
+ def initialize(config,opts={})
8
+ initialize_config(config,opts)
9
+ end
10
+
11
+ def send_stream(raw_data)
12
+ return "String data can only be sent via this service" unless raw_data.is_a? String
13
+ case @config[:type_of_service]
14
+ when "aws"
15
+ aws_firehose = StreamData::AwsStreamService.new(@config,@opts)
16
+ aws_firehose.send_stream(raw_data)
17
+ else
18
+ return "No data sent"
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def initialize_config(config,opts)
25
+ begin
26
+ @config = config || {}
27
+ @opts = opts || {}
28
+ @config[:type_of_service] || raise(StandardError.new('Specify the servcie type'))
29
+ @config[:service_key] || raise(StandardError.new('Service Key is missing, please specify in config'))
30
+ @config[:service_secret] || raise(StandardError.new('Service Secret is missing, please specify in config'))
31
+ @config[:delivery_stream_name] || raise(StandardError.new('Delivery Stream Name is missing, please specify in config'))
32
+ @config[:region] || raise(StandardError.new('Specify the Region'))
33
+ raise(StandardError.new('This type of servcie is not supported')) unless ALLOWED_SERVICE_TYPES.include?(@config[:type_of_service])
34
+ rescue Exception => e
35
+ raise(StandardError.new("Not a valid config, #{e.message}"))
36
+ end
37
+ end
38
+
39
+ end
40
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stream_data
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Saran
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-08-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk-firehose
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.4'
27
+ description: V1 Desc
28
+ email: saransai583@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/aws_stream_service.rb
34
+ - lib/stream_data.rb
35
+ homepage: ''
36
+ licenses:
37
+ - Nonstandard
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.7.6
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: V1
59
+ test_files: []