Class: EcsDeploy::AutoScaler::TriggerConfig
- Inherits:
-
Struct
- Object
- Struct
- EcsDeploy::AutoScaler::TriggerConfig
- Includes:
- ConfigBase
- Defined in:
- lib/ecs_deploy/auto_scaler.rb
Instance Attribute Summary collapse
-
#alarm_name ⇒ Object
Returns the value of attribute alarm_name.
-
#region ⇒ Object
Returns the value of attribute region.
-
#state ⇒ Object
Returns the value of attribute state.
-
#step ⇒ Object
Returns the value of attribute step.
Instance Method Summary collapse
Methods included from ConfigBase
Instance Attribute Details
#alarm_name ⇒ Object
Returns the value of attribute alarm_name
268 269 270 |
# File 'lib/ecs_deploy/auto_scaler.rb', line 268 def alarm_name @alarm_name end |
#region ⇒ Object
Returns the value of attribute region
268 269 270 |
# File 'lib/ecs_deploy/auto_scaler.rb', line 268 def region @region end |
#state ⇒ Object
Returns the value of attribute state
268 269 270 |
# File 'lib/ecs_deploy/auto_scaler.rb', line 268 def state @state end |
#step ⇒ Object
Returns the value of attribute step
268 269 270 |
# File 'lib/ecs_deploy/auto_scaler.rb', line 268 def step @step end |
Instance Method Details
#clear_client ⇒ Object
279 280 281 |
# File 'lib/ecs_deploy/auto_scaler.rb', line 279 def clear_client Thread.current["ecs_auto_scaler_cloud_watch_#{region}"] = nil end |
#client ⇒ Object
271 272 273 274 275 276 277 |
# File 'lib/ecs_deploy/auto_scaler.rb', line 271 def client Thread.current["ecs_auto_scaler_cloud_watch_#{region}"] ||= Aws::CloudWatch::Client.new( access_key_id: EcsDeploy.config.access_key_id, secret_access_key: EcsDeploy.config.secret_access_key, region: region ) end |
#fetch_alarm ⇒ Object
287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/ecs_deploy/auto_scaler.rb', line 287 def fetch_alarm res = client.describe_alarms(alarm_names: [alarm_name]) raise "Alarm \"#{alarm_name}\" is not found" if res.metric_alarms.empty? res.metric_alarms[0].tap do |alarm| AutoScaler.logger.debug("#{alarm.alarm_name} state is #{alarm.state_value}") end rescue => e AutoScaler.error_logger.error(e) clear_client end |
#match? ⇒ Boolean
283 284 285 |
# File 'lib/ecs_deploy/auto_scaler.rb', line 283 def match? fetch_alarm.state_value == state end |