Class: Telekinesis::Aws::JavaClientAdapter
- Inherits:
-
ClientAdapter
- Object
- ClientAdapter
- Telekinesis::Aws::JavaClientAdapter
- Defined in:
- lib/telekinesis/aws/java_client_adapter.rb
Overview
A ClientAdapter that wraps the AWS Java SDK.
Since the underlying Java client is thread safe, this adapter is thread safe.
Class Method Summary collapse
-
.build(credentials = {}) ⇒ Object
Build a new client adapter.
- .build_credentials_provider(credentials) ⇒ Object
Instance Method Summary collapse
Methods inherited from ClientAdapter
Constructor Details
This class inherits a constructor from Telekinesis::Aws::ClientAdapter
Class Method Details
.build(credentials = {}) ⇒ Object
Build a new client adapter. ‘credentials` is a hash keyed with `:access_key_id` and `:secret_access_key`. If this hash is left blank (the default) the client uses the DefaultAWSCredentialsProviderChain to look for credentials.
22 23 24 25 |
# File 'lib/telekinesis/aws/java_client_adapter.rb', line 22 def self.build(credentials = {}) client = AmazonKinesisClient.new(build_credentials_provider(credentials)) new(client) end |
.build_credentials_provider(credentials) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/telekinesis/aws/java_client_adapter.rb', line 27 def self.build_credentials_provider(credentials) if credentials.empty? DefaultAWSCredentialsProviderChain.new else StaticCredentialsProvider.new( BasicAWSCredentials.new( credentials[:access_key_id], credentials[:secret_access_key] ) ) end end |
Instance Method Details
#put_record(stream, key, value) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/telekinesis/aws/java_client_adapter.rb', line 40 def put_record(stream, key, value) r = PutRecordRequest.new.tap do |request| request.stream_name = stream request.partition_key = key.to_s request.data = ByteBuffer.wrap(value.to_s.to_java_bytes) end @client.put_record(r) rescue AmazonClientException => e raise KinesisError.new(e) end |