Class: KinesisCat::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(client, options) ⇒ Client

Returns a new instance of Client.



2
3
4
5
# File 'lib/kinesis_cat/client.rb', line 2

def initialize(client, options)
  @client = client
  @options = options
end

Instance Method Details

#put(data, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/kinesis_cat/client.rb', line 7

def put(data, options = {})
  options = @options.merge(options)
  partition_key = options[:partition_key]
  partition_key ||= Time.now.to_i.to_s

  if data.kind_of?(Hash)
    data = JSON.dump(data)
  end

  @client.put_record(
    :stream_name => options.fetch(:stream_name),
    :data => data,
    :partition_key => partition_key,
  )
end