Class: Cumulus::Kinesis::StreamConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/kinesis/models/StreamConfig.rb

Overview

Public: An object representing configuration for a Kiensis stream

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, json = nil) ⇒ StreamConfig

Public: Constructor

json - a hash containing the JSON configuration for the stream



20
21
22
23
24
25
26
27
# 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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/kinesis/models/StreamConfig.rb', line 12

def name
  @name
end

#retention_periodObject (readonly)

Returns the value of attribute retention_period.



13
14
15
# File 'lib/kinesis/models/StreamConfig.rb', line 13

def retention_period
  @retention_period
end

#shardsObject (readonly)

Returns the value of attribute shards.



14
15
16
# File 'lib/kinesis/models/StreamConfig.rb', line 14

def shards
  @shards
end

#tagsObject (readonly)

Returns the value of attribute tags.



15
16
17
# File 'lib/kinesis/models/StreamConfig.rb', line 15

def tags
  @tags
end

Instance Method Details

#diff(aws) ⇒ Object

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



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# 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) ⇒ Object

Public: Populate a config object with AWS configuration

aws - the AWS configuration for the strean



40
41
42
43
44
45
46
# 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_hashObject



29
30
31
32
33
34
35
# File 'lib/kinesis/models/StreamConfig.rb', line 29

def to_hash
  {
    "retention-period" => @retention_period,
    "shards" => @shards,
    "tags" => @tags
  }
end