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- RETRY_ATTEMPTS =
The DNS Made Easy API intermittently rejects rapid record mutations (rate limiting); short exponential backoff absorbs transient failures.
3- RETRY_BASE_SLEEP =
1.0
Instance Method Summary collapse
- #call ⇒ Object
-
#executable_action_count ⇒ Object
rubocop:enable Metrics/ParameterLists.
-
#initialize(client:, domain:, plan:, remote_records:, mode: :merge, spinner_factory: nil, spinner_output: $stderr, max_threads: DEFAULT_MAX_THREADS, sleeper: nil) ⇒ ApplyExecutor
constructor
rubocop:disable Metrics/ParameterLists -- dependency-injected executor.
Constructor Details
#initialize(client:, domain:, plan:, remote_records:, mode: :merge, spinner_factory: nil, spinner_output: $stderr, max_threads: DEFAULT_MAX_THREADS, sleeper: nil) ⇒ ApplyExecutor
rubocop:disable Metrics/ParameterLists -- dependency-injected executor
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/dnsmadeeasy/zone/apply_executor.rb', line 22 def initialize(client:, domain:, plan:, remote_records:, mode: :merge, spinner_factory: nil, spinner_output: $stderr, max_threads: DEFAULT_MAX_THREADS, sleeper: nil) @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 @sleeper = sleeper || ->(seconds) { sleep(seconds) } end |
Instance Method Details
#call ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/dnsmadeeasy/zone/apply_executor.rb', line 39 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
rubocop:enable Metrics/ParameterLists
35 36 37 |
# File 'lib/dnsmadeeasy/zone/apply_executor.rb', line 35 def executable_action_count executable_actions.length end |