Class: ZooStream::KinesisPublisher
- Inherits:
-
Object
- Object
- ZooStream::KinesisPublisher
- Defined in:
- lib/zoo_stream/kinesis_publisher.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#stream_name ⇒ Object
readonly
Returns the value of attribute stream_name.
Instance Method Summary collapse
-
#initialize(stream_name: ENV.fetch("ZOO_STREAM_KINESIS_STREAM_NAME"), client: Aws::Kinesis::Client.new) ⇒ KinesisPublisher
constructor
A new instance of KinesisPublisher.
- #publish(event, shard_by: nil) ⇒ Object
Constructor Details
#initialize(stream_name: ENV.fetch("ZOO_STREAM_KINESIS_STREAM_NAME"), client: Aws::Kinesis::Client.new) ⇒ KinesisPublisher
Returns a new instance of KinesisPublisher.
7 8 9 10 |
# File 'lib/zoo_stream/kinesis_publisher.rb', line 7 def initialize(stream_name: ENV.fetch("ZOO_STREAM_KINESIS_STREAM_NAME"), client: Aws::Kinesis::Client.new) @stream_name = stream_name @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/zoo_stream/kinesis_publisher.rb', line 5 def client @client end |
#stream_name ⇒ Object (readonly)
Returns the value of attribute stream_name.
5 6 7 |
# File 'lib/zoo_stream/kinesis_publisher.rb', line 5 def stream_name @stream_name end |
Instance Method Details
#publish(event, shard_by: nil) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/zoo_stream/kinesis_publisher.rb', line 12 def publish(event, shard_by: nil) raise ArgumentError, "Must specify shard_by" unless shard_by client.put_record( stream_name: stream_name, partition_key: shard_by, data: event.to_json ) end |