Class: Roadworker::Batch::Operation
- Inherits:
-
Object
- Object
- Roadworker::Batch::Operation
- Includes:
- Log
- Defined in:
- lib/roadworker/batch.rb
Instance Attribute Summary collapse
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
-
#health_checks ⇒ Object
readonly
Returns the value of attribute health_checks.
-
#hosted_zone ⇒ Object
readonly
Returns the value of attribute hosted_zone.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#rrset ⇒ Object
readonly
Returns the value of attribute rrset.
Instance Method Summary collapse
- #changes ⇒ Array<Hash>
-
#cname_first? ⇒ Boolean
CNAME should always be created/updated later, as CNAME doesn’t permit other records See also Roadworker::Batch::Delete#cname_first?.
- #desired_rrset ⇒ Hash
- #diff!(dry_run: false) ⇒ Object
-
#initialize(hosted_zone, rrset, health_checks:, dry_run:, logger:) ⇒ Operation
constructor
A new instance of Operation.
- #inspect ⇒ Object
- #op_size ⇒ Integer
- #present_rrset ⇒ Roadworker::Route53Wrapper::ResourceRecordSetWrapper
- #sort_key ⇒ Object
- #to_s ⇒ Object
-
#value_size ⇒ Integer
Count total length of RR “Value” included in changes docs.aws.amazon.com/Route53/latest/DeveloperGuide/DNSLimitations.html#limits-api-requests-changeresourcerecordsets.
Methods included from Log
Constructor Details
#initialize(hosted_zone, rrset, health_checks:, dry_run:, logger:) ⇒ Operation
Returns a new instance of Operation.
118 119 120 121 122 123 124 |
# File 'lib/roadworker/batch.rb', line 118 def initialize(hosted_zone, rrset, health_checks:, dry_run:, logger:) @hosted_zone = hosted_zone @rrset = rrset @health_checks = health_checks @dry_run = dry_run @logger = logger end |
Instance Attribute Details
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run.
128 129 130 |
# File 'lib/roadworker/batch.rb', line 128 def dry_run @dry_run end |
#health_checks ⇒ Object (readonly)
Returns the value of attribute health_checks.
127 128 129 |
# File 'lib/roadworker/batch.rb', line 127 def health_checks @health_checks end |
#hosted_zone ⇒ Object (readonly)
Returns the value of attribute hosted_zone.
126 127 128 |
# File 'lib/roadworker/batch.rb', line 126 def hosted_zone @hosted_zone end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
128 129 130 |
# File 'lib/roadworker/batch.rb', line 128 def logger @logger end |
#rrset ⇒ Object (readonly)
Returns the value of attribute rrset.
126 127 128 |
# File 'lib/roadworker/batch.rb', line 126 def rrset @rrset end |
Instance Method Details
#changes ⇒ Array<Hash>
180 181 182 |
# File 'lib/roadworker/batch.rb', line 180 def changes raise NotImplementedError end |
#cname_first? ⇒ Boolean
CNAME should always be created/updated later, as CNAME doesn’t permit other records See also Roadworker::Batch::Delete#cname_first?
148 149 150 |
# File 'lib/roadworker/batch.rb', line 148 def cname_first? false end |
#desired_rrset ⇒ Hash
185 186 187 |
# File 'lib/roadworker/batch.rb', line 185 def desired_rrset raise NotImplementedError end |
#diff!(dry_run: false) ⇒ Object
194 195 196 |
# File 'lib/roadworker/batch.rb', line 194 def diff!(dry_run: false) raise NotImplementedError end |
#inspect ⇒ Object
198 199 200 |
# File 'lib/roadworker/batch.rb', line 198 def inspect "#<#{self.class.name} @changes=#{changes.inspect}>" end |
#op_size ⇒ Integer
Count of operational size docs.aws.amazon.com/Route53/latest/DeveloperGuide/DNSLimitations.html#limits-api-requests-changeresourcerecordsets
See also: Batch#slice_operations
173 174 175 176 177 |
# File 'lib/roadworker/batch.rb', line 173 def op_size changes.map do |change| change[:action] == 'UPSERT' ? 2 : 1 end.sum || 0 end |
#present_rrset ⇒ Roadworker::Route53Wrapper::ResourceRecordSetWrapper
190 191 192 |
# File 'lib/roadworker/batch.rb', line 190 def present_rrset hosted_zone.find_resource_record_set(rrset.name, rrset.type, rrset.set_identifier) or raise "record not present" end |
#sort_key ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/roadworker/batch.rb', line 130 def sort_key # See Operation#cname_first? cname_precedence = if rrset.type == 'CNAME' cname_first? ? 0 : 2 else 1 end # Alias target may be created in the same change batch. Let's do operations for non-alias records first. alias_precedence = if rrset.dns_name 1 else 0 end [rrset.name, cname_precedence, alias_precedence, rrset.type, rrset.set_identifier] end |
#to_s ⇒ Object
202 203 204 |
# File 'lib/roadworker/batch.rb', line 202 def to_s inspect end |
#value_size ⇒ Integer
Count total length of RR “Value” included in changes docs.aws.amazon.com/Route53/latest/DeveloperGuide/DNSLimitations.html#limits-api-requests-changeresourcerecordsets
See also: Batch#slice_operations
157 158 159 160 161 162 163 164 165 166 |
# File 'lib/roadworker/batch.rb', line 157 def value_size changes.map do |change| upsert_multiplier = change[:action] == 'UPSERT' ? 2 : 1 rrset = change[:resource_record_set] next 0 unless rrset rrs = rrset[:resource_records] next 0 unless rrs (rrs.map { |_| _[:value]&.size || 0 }.sum) * upsert_multiplier end.sum || 0 end |