Class: Conrad::Emitters::Kinesis

Inherits:
AmazonBase show all
Defined in:
lib/conrad/emitters/kinesis.rb

Overview

Basic emitter for sending events to AWS’s kinesis event stream. The emitter will attempt to use values configured in the running environment according to the AWS SDK documentation (such as from ~/.aws/credentials).

Instance Attribute Summary collapse

Attributes inherited from AmazonBase

#access_key_id, #client, #region, #secret_access_key

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AmazonBase

#initialize

Constructor Details

This class inherits a constructor from Conrad::Emitters::AmazonBase

Instance Attribute Details

#stream_nameString

Returns the configured kinesis stream name.

Returns:

  • (String)

    the configured kinesis stream name



12
13
14
# File 'lib/conrad/emitters/kinesis.rb', line 12

def stream_name
  @stream_name
end

Class Method Details

.client_classObject



28
29
30
# File 'lib/conrad/emitters/kinesis.rb', line 28

def client_class
  Aws::Kinesis::Client
end

Instance Method Details

#call(event) ⇒ Object

Sends an event up to Kinesis

Parameters:

  • event (String)

    the event to be sent as a Kinesis message body



17
18
19
20
21
22
23
24
25
# File 'lib/conrad/emitters/kinesis.rb', line 17

def call(event)
  client.put_record(
    stream_name: stream_name,
    data: event,
    # There's a 256 character limit on the partition key, and it's hashed down into a value used to
    # pick the shard to put the data on
    partition_key: event.first(255)
  )
end