Class: StreamData::Stream

Inherits:
Object
  • Object
show all
Defined in:
lib/stream.rb

Class Method Summary collapse

Class Method Details

.send_raw_data(raw_data) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/stream.rb', line 22

def self.send_raw_data(raw_data)
  begin
    @firehose.put_record({ delivery_stream_name: @config["delivery_stream_name"],  record: { data: raw_data}})
  rescue Aws::Errors::MissingCredentialsError => e
    raise (StandardError.new("Error with the connection. Check the config. Error message === #{e.message}"))
  end
end

.send_stream(config, raw_data) ⇒ Object



4
5
6
7
# File 'lib/stream.rb', line 4

def self.send_stream(config,raw_data)
  set_connection(config)
  send_raw_data(raw_data)
end

.set_connection(config) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/stream.rb', line 9

def self.set_connection(config)
  @config = config || {}
  begin
    @firehose = Aws::Firehose::Client.new(
    access_key_id: @config["service_key"],
    secret_access_key: @config["service_secret"],
    region: @config["region"]
    )
  rescue Exception => e
    raise (StandardError.new("Could not establish a connection. Check the config. Error message === #{e.message}"))
  end
end