Class: Cumulus::Kinesis::StreamConfig
- Inherits:
-
Object
- Object
- Cumulus::Kinesis::StreamConfig
- Defined in:
- lib/kinesis/models/StreamConfig.rb
Overview
Public: An object representing configuration for a Kiensis stream
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#retention_period ⇒ Object
readonly
Returns the value of attribute retention_period.
-
#shards ⇒ Object
readonly
Returns the value of attribute shards.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
-
#diff(aws) ⇒ Object
Public: Produce an array of differences between this local configuration and the configuration in AWS.
-
#initialize(name, json = nil) ⇒ StreamConfig
constructor
Public: Constructor.
-
#populate!(aws) ⇒ Object
Public: Populate a config object with AWS configuration.
- #to_hash ⇒ Object
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/kinesis/models/StreamConfig.rb', line 12 def name @name end |
#retention_period ⇒ Object (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 |
#shards ⇒ Object (readonly)
Returns the value of attribute shards.
14 15 16 |
# File 'lib/kinesis/models/StreamConfig.rb', line 14 def shards @shards end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
15 16 17 |
# File 'lib/kinesis/models/StreamConfig.rb', line 15 def @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 = Kinesis::[aws.stream_name] if @tags != diffs << StreamDiff.new(StreamChange::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::[aws.stream_name] || {} self end |
#to_hash ⇒ Object
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 |