aktivlearn_stream 0.0.6
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 +7 -0
- data/lib/aktivlearn_stream.rb +13 -0
- data/lib/config.rb +26 -0
- data/lib/stream.rb +31 -0
- data/lib/stream_config.yml +5 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e27e734af4af4859190c9146291170841c67c74798bbee53983ba7f9722b780c
|
4
|
+
data.tar.gz: bf5dc09a2060c2ee9ce656399c4581a2e021001990e4ec602d70a676d6575e4c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 38e60707e831b889809645c956d24c8a6ad089f24d0d8c495f8d9a681ae51b69c89fa05baee3d45b121c38ca159e45d75e9094386bec0aca0d71345d29c4e1e6
|
7
|
+
data.tar.gz: af1eeecc633129ea77a616cb8bd35d3bf6282c4f5b3cde90d6d4f9ac90b47553d2a177123dee9da4f6bee90c2cf881ca699153b692f1b9b510bab8c7d707c9bd
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'aws_stream_service'
|
2
|
+
require 'config'
|
3
|
+
require 'stream'
|
4
|
+
module AktivlearnStream
|
5
|
+
|
6
|
+
@config = AktivlearnStream::Config.read_config
|
7
|
+
|
8
|
+
def self.send(raw_data)
|
9
|
+
AktivlearnStream::Config.validate_config
|
10
|
+
AktivlearnStream::Stream.send_stream(@config,raw_data)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/lib/config.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module AktivlearnStream
|
2
|
+
class Config
|
3
|
+
require 'aws_stream_service'
|
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
|
+
|
10
|
+
ALLOWED_SERVICE_TYPES = ["azure","aws"]
|
11
|
+
|
12
|
+
def self.validate_config
|
13
|
+
begin
|
14
|
+
@config["type_of_service"] || raise(StandardError.new('Specify the servcie type'))
|
15
|
+
@config["service_key"] || raise(StandardError.new('Service Key is missing, please specify in config'))
|
16
|
+
@config["service_secret"] || raise(StandardError.new('Service Secret is missing, please specify in config'))
|
17
|
+
@config["delivery_stream_name"] || raise(StandardError.new('Delivery Stream Name is missing, please specify in config'))
|
18
|
+
@config["region"] || raise(StandardError.new('Specify the Region'))
|
19
|
+
raise(StandardError.new('This type of servcie is not supported')) unless ALLOWED_SERVICE_TYPES.include?(@config["type_of_service"])
|
20
|
+
rescue Exception => e
|
21
|
+
raise(StandardError.new("Not a valid config,Error === #{e.message}"))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/stream.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module AktvlearnStream
|
2
|
+
class Stream
|
3
|
+
|
4
|
+
def self.send_stream(config,raw_data)
|
5
|
+
set_connection(config)
|
6
|
+
send_raw_data(raw_data)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.set_connection(config)
|
10
|
+
@config = config || {}
|
11
|
+
begin
|
12
|
+
@firehose = Aws::Firehose::Client.new(
|
13
|
+
access_key_id: @config["service_key"],
|
14
|
+
secret_access_key: @config["service_secret"],
|
15
|
+
region: @config["region"]
|
16
|
+
)
|
17
|
+
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
|
+
raise (StandardError.new("Error with the connection. Check the config. Error message === #{e.message}"))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aktivlearn_stream
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
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: 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
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aws-sdk
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 3.0.1
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.0'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.0.1
|
47
|
+
description: V1 Desc
|
48
|
+
email: saransai583@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- lib/aktivlearn_stream.rb
|
54
|
+
- lib/config.rb
|
55
|
+
- lib/stream.rb
|
56
|
+
- lib/stream_config.yml
|
57
|
+
homepage: ''
|
58
|
+
licenses:
|
59
|
+
- Nonstandard
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.7.6
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: V1
|
81
|
+
test_files: []
|