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 = []) ⇒ Object
- #scale_options_to_set ⇒ Object
- #scale_string_to_hash(scale_string) ⇒ Object
Instance Method Details
#adjust_scale ⇒ Object
7 8 9 10 11 |
# File 'lib/satorix/CI/deploy/flynn/scale.rb', line 7 def adjust_scale = log "No scale specified in #{ defined_scale_key }. Displaying current scale:" if .empty? fc_scale end |
#current_scale ⇒ Object
14 15 16 |
# File 'lib/satorix/CI/deploy/flynn/scale.rb', line 14 def current_scale scale_string_to_hash fc_scale end |
#defined_scale ⇒ Object
19 20 21 |
# File 'lib/satorix/CI/deploy/flynn/scale.rb', line 19 def defined_scale scale_string_to_hash ENV[defined_scale_key].to_s end |
#defined_scale_key ⇒ Object
24 25 26 |
# File 'lib/satorix/CI/deploy/flynn/scale.rb', line 24 def defined_scale_key "FLYNN_#{ current_branch }_SCALE" end |
#fc_scale(scale_options_to_set = []) ⇒ Object
29 30 31 32 33 |
# File 'lib/satorix/CI/deploy/flynn/scale.rb', line 29 def fc_scale( = []) command = %w[flynn scale].concat() run_command(command) end |
#scale_options_to_set ⇒ Object
36 37 38 39 40 41 |
# File 'lib/satorix/CI/deploy/flynn/scale.rb', line 36 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 end |
#scale_string_to_hash(scale_string) ⇒ Object
44 45 46 |
# File 'lib/satorix/CI/deploy/flynn/scale.rb', line 44 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 |