class Cumulus::Kinesis::StreamConfig

Public: An object representing configuration for a Kiensis stream

Attributes

name[R]
retention_period[R]
shards[R]
tags[R]

Public Class Methods

new(name, json = nil) click to toggle source

Public: Constructor

json - a hash containing the JSON configuration for the stream

# File lib/kinesis/models/StreamConfig.rb, line 20
def initialize(name, json = nil)
  @name = name
  if !json.nil?
    @shards = json["shards"]
    @retention_period = json["retention-period"] || 24
    @tags = json["tags"] || {}
  end
end

Public Instance Methods

diff(aws) click to toggle source

Public: Produce an array of differences between this local configuration and the configuration in AWS

aws - the AWS resource

Returns an array of the StreamDiffs that were found

# File lib/kinesis/models/StreamConfig.rb, line 54
def diff(aws)
  diffs = []

  if @retention_period != aws.retention_period_hours
    diffs << StreamDiff.new(StreamChange::RETENTION, aws.retention_period_hours, @retention_period)
  end

  if @shards != aws.sorted_shards.length
    diffs << StreamDiff.new(StreamChange::SHARDS, aws.sorted_shards.length, @shards)
  end

  aws_tags = Kinesis::stream_tags[aws.stream_name]
  if @tags != aws_tags
    diffs << StreamDiff.new(StreamChange::TAGS, aws_tags, @tags)
  end

  diffs
end
populate!(aws) click to toggle source

Public: Populate a config object with AWS configuration

aws - the AWS configuration for the strean

# File lib/kinesis/models/StreamConfig.rb, line 40
def populate!(aws)
  @retention_period = aws.retention_period_hours
  @shards = aws.sorted_shards.length
  @tags = Kinesis::stream_tags[aws.stream_name] || {}

  self
end
to_hash() click to toggle source
# File lib/kinesis/models/StreamConfig.rb, line 29
def to_hash
  {
    "retention-period" => @retention_period,
    "shards" => @shards,
    "tags" => @tags
  }
end