Module: Satorix::CI::Deploy::Flynn::Scale
- Included in:
- Satorix::CI::Deploy::Flynn
- Defined in:
- lib/satorix/CI/deploy/flynn/scale.rb
Instance Method Summary collapse
- #adjust_scale ⇒ Object
- #current_scale ⇒ Object
- #defined_scale ⇒ Object
- #defined_scale_key ⇒ Object
- #fc_scale(scale_options_to_set = nil) ⇒ Object
- #scale_options_to_set ⇒ Object
- #scale_string_to_hash(scale_string) ⇒ Object
Instance Method Details
#adjust_scale ⇒ Object
8 9 10 11 12 |
# File 'lib/satorix/CI/deploy/flynn/scale.rb', line 8 def adjust_scale = log "No scale specified in #{ defined_scale_key }. Displaying current scale:" if .empty? fc_scale end |
#current_scale ⇒ Object
15 16 17 |
# File 'lib/satorix/CI/deploy/flynn/scale.rb', line 15 def current_scale scale_string_to_hash fc_scale end |
#defined_scale ⇒ Object
20 21 22 |
# File 'lib/satorix/CI/deploy/flynn/scale.rb', line 20 def defined_scale scale_string_to_hash ENV[defined_scale_key].to_s end |
#defined_scale_key ⇒ Object
25 26 27 |
# File 'lib/satorix/CI/deploy/flynn/scale.rb', line 25 def defined_scale_key "FLYNN_#{ current_branch }_SCALE" end |
#fc_scale(scale_options_to_set = nil) ⇒ Object
30 31 32 |
# File 'lib/satorix/CI/deploy/flynn/scale.rb', line 30 def fc_scale( = nil) run_command "flynn scale#{ " #{ }" unless .nil? || .empty? }".chomp end |
#scale_options_to_set ⇒ Object
35 36 37 38 39 40 |
# File 'lib/satorix/CI/deploy/flynn/scale.rb', line 35 def [].tap do |scale| defined_scale.each { |job, workers| scale << "#{ job }=#{ workers }" } (current_scale.keys - defined_scale.keys).each { |job| scale << "#{ job }=0" } unless defined_scale.empty? end.join(' ') end |
#scale_string_to_hash(scale_string) ⇒ Object
43 44 45 |
# File 'lib/satorix/CI/deploy/flynn/scale.rb', line 43 def scale_string_to_hash(scale_string) {}.tap { |jobs| scale_string.split.map { |x| x.partition('=') }.each { |x| jobs[x.first.to_sym] = x.last } } end |