Class: Telekinesis::Aws::ClientAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/telekinesis/aws/client_adapter.rb

Overview

Base class for other ClientAdapters. Client adapters exist to make switching between platforms easy and painless.

The base adapter defines the interface and provides convience methods.

Direct Known Subclasses

JavaClientAdapter

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ ClientAdapter

Returns a new instance of ClientAdapter.



25
26
27
# File 'lib/telekinesis/aws/client_adapter.rb', line 25

def initialize(client)
  @client = client
end

Class Method Details

.build(credentials) ⇒ Object

Build a new client given AWS credentials.

Credentials must be supplied as a hash that contains symbolized :access_key_id and :secret_access_key keys.

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/telekinesis/aws/client_adapter.rb', line 21

def self.build(credentials)
  raise NotImplementedError
end

Instance Method Details

#put_record(stream, key, value) ⇒ Object

Make a put_record call to the underlying client. Must return an object that responds to ‘shard_id` and `sequence_number`.

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/telekinesis/aws/client_adapter.rb', line 31

def put_record(stream, key, value)
  raise NotImplementedError
end

#put_records(stream, items) ⇒ Object

Make a put_records call to the underlying client. If the request succeeds but returns errors for some records, the original [key, value] pair is zipped with the [error_code, error_message] pair and the offending records are returned.



39
40
41
42
43
44
45
46
# File 'lib/telekinesis/aws/client_adapter.rb', line 39

def put_records(stream, items)
  response = do_put_records(stream, items)
  failures = items.zip(response).reject{|_, r| r.error_code.nil?}

  failures.map do |(k, v), r|
    [k, v, r.error_code, r.error_message]
  end
end