Class: DnsMadeEasy::Zone::ApplyExecutor
- Inherits:
-
Object
- Object
- DnsMadeEasy::Zone::ApplyExecutor
- Defined in:
- lib/dnsmadeeasy/zone/apply_executor.rb
Overview
Executes safe plan actions against DNS Made Easy.
Constant Summary collapse
- MODES =
%i[merge add_only delete_only].freeze
- DEFAULT_MAX_THREADS =
4
Instance Method Summary collapse
- #call ⇒ Object
- #executable_action_count ⇒ Object
-
#initialize(client:, domain:, plan:, remote_records:, mode: :merge, spinner_factory: nil, spinner_output: $stderr, max_threads: DEFAULT_MAX_THREADS) ⇒ ApplyExecutor
constructor
A new instance of ApplyExecutor.
Constructor Details
#initialize(client:, domain:, plan:, remote_records:, mode: :merge, spinner_factory: nil, spinner_output: $stderr, max_threads: DEFAULT_MAX_THREADS) ⇒ ApplyExecutor
Returns a new instance of ApplyExecutor.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/dnsmadeeasy/zone/apply_executor.rb', line 16 def initialize(client:, domain:, plan:, remote_records:, mode: :merge, spinner_factory: nil, spinner_output: $stderr, max_threads: DEFAULT_MAX_THREADS) @client = client @domain = domain @plan = plan @remote_records = remote_records @mode = mode @spinner_factory = spinner_factory || default_spinner_factory(spinner_output) @max_threads = [max_threads.to_i, 1].max end |
Instance Method Details
#call ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dnsmadeeasy/zone/apply_executor.rb', line 31 def call return Failure(["Unsupported apply mode: #{mode}"]) unless MODES.include?(mode) applied_actions, failed_actions = execute_actions(executable_actions) Success(ApplyResult.new( applied_actions: applied_actions, failed_actions: failed_actions, skipped_actions: skipped_actions )) end |
#executable_action_count ⇒ Object
27 28 29 |
# File 'lib/dnsmadeeasy/zone/apply_executor.rb', line 27 def executable_action_count executable_actions.length end |