Class: Sbmt::Strangler::WorkModes::Mirror

Inherits:
Base
  • Object
show all
Includes:
Dry::Monads::Result::Mixin
Defined in:
lib/sbmt/strangler/work_modes/mirror.rb

Instance Attribute Summary

Attributes inherited from Base

#feature_flags, #metric_tracker, #rails_controller, #strangler_action

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Sbmt::Strangler::WorkModes::Base

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sbmt/strangler/work_modes/mirror.rb', line 11

def call
  mirror_task = Concurrent::Promises.future { mirror_call }
  proxy_task = Concurrent::Promises.future { http_request(http_params) }

  mirror_call_result = mirror_task.value!
  origin_response = proxy_task.value!

  begin
    track_mirror_call(mirror_call_result.success?)
    if mirror_call_result.success?
      mirror_result = mirror_call_result.value!
      origin_result = copy_of_origin_result(origin_response)
      compare_call_result = compare_call(origin_result, mirror_result)
      track_compare_call(compare_call_result.success?)
      track_compare_call_result(compare_call_result.value!) if compare_call_result.success?
    end
  rescue => err
    handle_error(err)
  end

  render_origin_response(origin_response)
end