Class: Legion::CLI::Failover
- Inherits:
-
Thor
- Object
- Thor
- Legion::CLI::Failover
- Defined in:
- lib/legion/cli/failover_command.rb
Instance Method Summary collapse
Instance Method Details
#promote ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/legion/cli/failover_command.rb', line 19 def promote out = formatter ensure_settings target = [:region] require 'legion/region/failover' if [:dry_run] run_dry_run(out, target) else run_promote(out, target) end rescue Legion::Region::Failover::UnknownRegionError => e out.error(e.) raise SystemExit, 1 rescue Legion::Region::Failover::LagTooHighError => e if [:force] out.warn("#{e.} — forcing promotion") force_promote(out, target) else out.error("#{e.}. Use --force to override.") raise SystemExit, 1 end end |
#status ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/legion/cli/failover_command.rb', line 45 def status out = formatter ensure_settings region_config = Legion::Settings[:region] || {} if [:json] out.json(region_config) else out.header('Region Configuration') out.detail({ current: region_config[:current] || '(not set)', primary: region_config[:primary] || '(not set)', failover: region_config[:failover] || '(not set)', peers: (region_config[:peers] || []).join(', ').then { |s| s.empty? ? '(none)' : s }, default_affinity: region_config[:default_affinity] || 'prefer_local' }) end end |