Created
January 20, 2014 04:03
-
-
Save maraca/8514708 to your computer and use it in GitHub Desktop.
Basic Kinesis clients that writes a 100 strings to a Kinesis shard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| source 'https://rubygems.org' | |
| gem 'aws-sdk-core', '2.0.0.rc4' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ 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