Class: Dash::Configuration::Boot
- Inherits:
-
Object
- Object
- Dash::Configuration::Boot
- Includes:
- Validation
- Defined in:
- lib/dash/configuration/boot.rb
Instance Attribute Summary collapse
-
#boot_config ⇒ Object
readonly
Returns the value of attribute boot_config.
Instance Method Summary collapse
-
#canary ⇒ Object
How many primary-role hosts boot alone, one at a time, before the rest boot together.
- #canary? ⇒ Boolean
-
#groups? ⇒ Boolean
Whether this config splits hosts into more than one group at all — what
waitneeds in order to mean anything. -
#initialize(config:, boot_config: nil, context: nil) ⇒ Boot
constructor
Pass boot_config/context to scope this to a single role: the role's own
boot:hash, and a context that points at the role in validation errors. -
#limit? ⇒ Boolean
Whether a limit is configured at all.
-
#limit_for(hosts) ⇒ Object
The group size to slice
hostsby. - #parallel_roles ⇒ Object
-
#runner_options_for(hosts) ⇒ Object
SSHKit runner options expressing this pacing over
hosts. - #wait ⇒ Object
Methods included from Validation
Constructor Details
#initialize(config:, boot_config: nil, context: nil) ⇒ Boot
Pass boot_config/context to scope this to a single role: the role's own boot: hash,
and a context that points at the role in validation errors.
8 9 10 11 12 |
# File 'lib/dash/configuration/boot.rb', line 8 def initialize(config:, boot_config: nil, context: nil) @boot_config = boot_config || config.raw_config.boot || {} validate! @boot_config, context: context validate_canary!(context || self.class.validation_config_key) end |
Instance Attribute Details
#boot_config ⇒ Object (readonly)
Returns the value of attribute boot_config.
4 5 6 |
# File 'lib/dash/configuration/boot.rb', line 4 def boot_config @boot_config end |
Instance Method Details
#canary ⇒ Object
How many primary-role hosts boot alone, one at a time, before the rest boot together. Whole-deploy only — Cli::App#host_boot_groups is the sole consumer.
41 42 43 |
# File 'lib/dash/configuration/boot.rb', line 41 def canary boot_config["canary"] end |
#canary? ⇒ Boolean
45 46 47 |
# File 'lib/dash/configuration/boot.rb', line 45 def canary? canary.present? end |
#groups? ⇒ Boolean
Whether this config splits hosts into more than one group at all — what wait needs
in order to mean anything.
51 52 53 |
# File 'lib/dash/configuration/boot.rb', line 51 def groups? limit? || canary? end |
#limit? ⇒ Boolean
Whether a limit is configured at all. Deliberately not a reader for the raw value: a percentage means nothing without the hosts it slices, so anything that needs the group size has to go through limit_for.
31 32 33 |
# File 'lib/dash/configuration/boot.rb', line 31 def limit? boot_config["limit"].present? end |
#limit_for(hosts) ⇒ Object
The group size to slice hosts by. A percentage only means something against the set
it will actually be applied to, and that set is not known until run time — --roles
and --hosts narrow it, and accessories are never booted at all. So callers pass the
hosts they are about to group rather than Boot reaching for a host list of its own.
18 19 20 21 22 23 24 25 26 |
# File 'lib/dash/configuration/boot.rb', line 18 def limit_for(hosts) limit = boot_config["limit"] if limit.to_s.end_with?("%") [ hosts.count * limit.to_i / 100, 1 ].max else limit end end |
#parallel_roles ⇒ Object
55 56 57 |
# File 'lib/dash/configuration/boot.rb', line 55 def parallel_roles boot_config["parallel_roles"] end |
#runner_options_for(hosts) ⇒ Object
SSHKit runner options expressing this pacing over hosts. Without a limit there is
nothing to pace and on keeps its default parallel runner.
wait is always explicit: SSHKit::Runner::Sequential and ::Group both fall back to a
2 second interval, where Kamal's own boot wait means "no sleep unless you asked for
one". A limit of 1 goes through Sequential rather than Group, which runs one host per
slice without spawning a thread to do it. Neither trails a wait past the last group —
Sequential pops its final host, and Kamal patches Group to match (sshkit_with_ext.rb).
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/dash/configuration/boot.rb', line 67 def (hosts) limit = limit_for(hosts) return {} unless limit if limit == 1 { in: :sequence, wait: wait.to_i } else { in: :groups, limit: limit, wait: wait.to_i } end end |
#wait ⇒ Object
35 36 37 |
# File 'lib/dash/configuration/boot.rb', line 35 def wait boot_config["wait"] end |