Class: HttpKinesis::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/http-kinesis/client.rb

Overview

An AWS Amazon Kinesis Client

Instance Method Summary collapse

Constructor Details

#initialize(region, credentials) ⇒ Client

Instantiates an HttpKinesis::Client object

Parameters:

  • region (String)

    A valid AWS region supporting AWS Kinesis Streams

  • credentials (HttpKinesis::Credentials)

    A credentials object


15
16
17
18
# File 'lib/http-kinesis/client.rb', line 15

def initialize(region, credentials)
  @region = Region.new(region)
  @credentials = credentials
end

Instance Method Details

#describe_stream(stream_name) ⇒ Object

Method not yet implemented

Raises:


30
31
32
33
# File 'lib/http-kinesis/client.rb', line 30

def describe_stream(stream_name)
  raise Error.new("Not yet implemented: HttpKinesis::Client#describe_stream")
  # see http://docs.aws.amazon.com/kinesis/latest/APIReference/API_DescribeStream.html
end

#get_records(shard_iterator, limit) ⇒ GetRecordsResponse

Returns a GetRecordsResponse from the stream

Parameters:

  • shard_iterator (String)

    The Shard iterator from which to start reading

  • limit (Integer)

    The maximum number of records to return (between 1 and 10,000)

Returns:


55
56
57
# File 'lib/http-kinesis/client.rb', line 55

def get_records(shard_iterator, limit)
  RecordGetter.new(@region, @credentials, shard_iterator, limit).get
end

#get_shard_iterator(opts) ⇒ String

Returns a shard iterator fo the requested type for the named steam

Parameters:

  • opts (Hash)

    A hash of options as described below.

Options Hash (opts):

  • :stream_name (String)

    The stream for which an iterator is to be returned (required).

  • :shard_id (String) — default: required

    .

  • :shard_iterator_type (String)

    The type of shard iterator (required). Must be one of AT_SEQUENCE_NUMBER, AFTER_SEQUENCE_NUMBER, TRIM_HORIZON, LATEST, AT_TIMESTAMP,

  • :starting_sequence_number (String)

    The sequence number (only for shard iterator types AT_SEQUENCE_NUMBER, AFTER_SEQUENCE_NUMBER)

  • :timestamp (Time)

    The timestamp (only for shard iterator types AT_TIMESTAMP)

Returns:

  • (String)

    The shard iterator


45
46
47
# File 'lib/http-kinesis/client.rb', line 45

def get_shard_iterator(opts)
  IteratorGetter.new(@region, @credentials, opts).get
end

#put_record(opts) ⇒ Types::PutRecordResponse

Writes a record to the named stream.

Parameters:

  • opts (Hash)

    A has of options as described below.

Options Hash (opts):

  • :stream_name (String, required)

    The name of the stream to put the data record into.

  • :data (String, required)

    The data blob to put into the record, which will be base64 encoded when the blob is serialised.

  • :partition_key (String, required)

    Determines which shard in the stream the data record is assigned to. Partition keys are Unicode strings with a maximum length limit of 256 characters for each key. Amazon Kinesis uses the partition key as input to a hash function that maps the partition key and associated data to a specific shard. Specifically, an MD5 hash function is used to map partition keys to 128-bit integer values and to map associated data records to shards. As a result of this hashing mechanism, all data records with the same partition key map to the same shard within the stream.

  • :explicit_hash_key (String)

    The hash value used to explicitly determine the shard the data record is assigned to by overriding the partition key hash.

  • :sequence_number_for_ordering (String)

    Guarantees strictly increasing sequence numbers, for puts from the same client and to the same partition key. Usage: set the SequenceNumberForOrdering of record n to the sequence number of record n-1 (as returned in the result when putting record n-1). If this parameter is not set, records will be coarsely ordered based on arrival time.

Returns:


76
77
78
# File 'lib/http-kinesis/client.rb', line 76

def put_record(opts)
  RecordPutter.new(@region, @credentials, opts).put
end