aktivlearn_stream 0.0.7 → 0.0.8
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 +4 -4
- data/lib/aktivlearn_stream.rb +20 -3
- data/lib/config.rb +4 -9
- data/lib/stream.rb +3 -21
- metadata +1 -16
- data/lib/stream_config.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 803c0082b751aca32ce39ad57f5245bbbf41463db51668c2977537ecbd658ef9
|
4
|
+
data.tar.gz: 9ac8ddb81cf8657ad286ff4ccbb34a3bce03d0268798625bb0600d59158c0198
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b8ef74ae4ea1e3c03d9de5b57a240d6668c1eefc48374cabddeadec46b2cb293febbb6097939984f46bea5c296420410b6dac519d8a55fd2c2738c009273862
|
7
|
+
data.tar.gz: 0f0ffb35606743cfd82d9a86fb2d7de25a7a8b837cb68aa9a17a2a89b6e276fd1d89feae82e18db5f04d9bf2864c09d677ae1d0c57f4e29e5687b4e410495399
|
data/lib/aktivlearn_stream.rb
CHANGED
@@ -2,11 +2,28 @@ require 'config'
|
|
2
2
|
require 'stream'
|
3
3
|
module AktivlearnStream
|
4
4
|
|
5
|
-
|
5
|
+
def self.read_config config
|
6
|
+
@config = config
|
7
|
+
AktivlearnStream::Config.validate_config(@config)
|
8
|
+
set_connection
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def self.set_connection
|
13
|
+
@config ||= {}
|
14
|
+
begin
|
15
|
+
@firehose = Aws::Firehose::Client.new(
|
16
|
+
access_key_id: @config["service_key"],
|
17
|
+
secret_access_key: @config["service_secret"],
|
18
|
+
region: @config["region"]
|
19
|
+
)
|
20
|
+
rescue Exception => e
|
21
|
+
raise (StandardError.new("Could not establish a connection. Check the config. Error message === #{e.message}"))
|
22
|
+
end
|
23
|
+
end
|
6
24
|
|
7
25
|
def self.send(raw_data)
|
8
|
-
AktivlearnStream::
|
9
|
-
AktivlearnStream::Stream.send_stream(@config,raw_data)
|
26
|
+
AktivlearnStream::Stream.send_raw_data(@config,@firehose,raw_data)
|
10
27
|
end
|
11
28
|
|
12
29
|
end
|
data/lib/config.rb
CHANGED
@@ -1,16 +1,11 @@
|
|
1
1
|
module AktivlearnStream
|
2
2
|
class Config
|
3
|
-
|
4
|
-
require 'yaml'
|
5
|
-
require 'rails'
|
6
|
-
def self.read_config
|
7
|
-
@config = YAML.load_file(Rails.root + 'config/stream_config.yml') rescue nil
|
8
|
-
end
|
9
|
-
|
3
|
+
|
10
4
|
ALLOWED_SERVICE_TYPES = ["azure","aws"]
|
11
|
-
|
12
|
-
def self.validate_config
|
5
|
+
|
6
|
+
def self.validate_config(config)
|
13
7
|
begin
|
8
|
+
@config = config || {}
|
14
9
|
@config["type_of_service"] || raise(StandardError.new('Specify the servcie type'))
|
15
10
|
@config["service_key"] || raise(StandardError.new('Service Key is missing, please specify in config'))
|
16
11
|
@config["service_secret"] || raise(StandardError.new('Service Secret is missing, please specify in config'))
|
data/lib/stream.rb
CHANGED
@@ -1,28 +1,10 @@
|
|
1
|
-
module
|
1
|
+
module AktivlearnStream
|
2
2
|
class Stream
|
3
3
|
|
4
|
-
def self.
|
5
|
-
set_connection(config)
|
6
|
-
send_raw_data(raw_data)
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.set_connection(config)
|
10
|
-
@config = config || {}
|
4
|
+
def self.send_raw_data(config,firehose,raw_data)
|
11
5
|
begin
|
12
|
-
|
13
|
-
access_key_id: @config["service_key"],
|
14
|
-
secret_access_key: @config["service_secret"],
|
15
|
-
region: @config["region"]
|
16
|
-
)
|
6
|
+
firehose.put_record({ delivery_stream_name: config["delivery_stream_name"], record: { data: raw_data}})
|
17
7
|
rescue Exception => e
|
18
|
-
raise (StandardError.new("Could not establish a connection. Check the config. Error message === #{e.message}"))
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.send_raw_data(raw_data)
|
23
|
-
begin
|
24
|
-
@firehose.put_record({ delivery_stream_name: @config["delivery_stream_name"], record: { data: raw_data}})
|
25
|
-
rescue Aws::Errors::MissingCredentialsError => e
|
26
8
|
raise (StandardError.new("Error with the connection. Check the config. Error message === #{e.message}"))
|
27
9
|
end
|
28
10
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aktivlearn_stream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saran
|
@@ -10,20 +10,6 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2018-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rails
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 4.0.13
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - '='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 4.0.13
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: aws-sdk
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,7 +39,6 @@ files:
|
|
53
39
|
- lib/aktivlearn_stream.rb
|
54
40
|
- lib/config.rb
|
55
41
|
- lib/stream.rb
|
56
|
-
- lib/stream_config.yml
|
57
42
|
homepage: ''
|
58
43
|
licenses:
|
59
44
|
- Nonstandard
|