Skip to content

Instantly share code, notes, and snippets.

@maraca
Created January 20, 2014 04:03
Show Gist options
  • Select an option

  • Save maraca/8514708 to your computer and use it in GitHub Desktop.

Select an option

Save maraca/8514708 to your computer and use it in GitHub Desktop.
Basic Kinesis clients that writes a 100 strings to a Kinesis shard.
require 'aws-sdk-core'
class Client
def initialize stream_name, endpoint, partition_key
@stream_name = stream_name
@endpoint = endpoint
@partition_key = partition_key
@kinesis = Aws::Kinesis.new(region: @endpoint)
end
def list_streams
return @kinesis.list_streams()
end
def put data
return @kinesis.put_record(:stream_name => @stream_name,
:data => data,
:partition_key => @partition_key)
end
end
client = Client.new('analytics',
'us-east-1',
'workerId0')
for id in 1..100
data = "ID: #{id}"
client.put(data)
sleep(1.0/2)
puts data
end
source 'https://rubygems.org'
gem 'aws-sdk-core', '2.0.0.rc4'
$ ruby client.rb
ID: 1
ID: 2
ID: 3
ID: 4
ID: 5
ID: 6
ID: 7
ID: 8
ID: 9
ID: 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment