Class: Diffend::Track
- Inherits:
-
Object
- Object
- Diffend::Track
- Defined in:
- lib/diffend/track.rb
Overview
Track what is run in production
Constant Summary collapse
- TRACK_SLEEP =
Time that we want to wait between track requests
15
- RETRY_SLEEP =
Time that we want to wait before we retry
15
Instance Method Summary collapse
- #build_request_object(request_id) ⇒ Diffend::RequestObject
-
#initialize(config) ⇒ Track
constructor
Initialize tracking.
- #perform(request_id) ⇒ Object
-
#start ⇒ Object
Start tracking.
-
#track_request(request_id) ⇒ Object
Perform a track request.
Constructor Details
#initialize(config) ⇒ Track
Initialize tracking
14 15 16 17 |
# File 'lib/diffend/track.rb', line 14 def initialize(config) @mutex = Mutex.new @config = config end |
Instance Method Details
#build_request_object(request_id) ⇒ Diffend::RequestObject
63 64 65 66 67 68 69 70 |
# File 'lib/diffend/track.rb', line 63 def build_request_object(request_id) Diffend::RequestObject.new( @config, @config.track_url(request_id), { id: request_id }.freeze, :put ).freeze end |
#perform(request_id) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/diffend/track.rb', line 43 def perform(request_id) loop do @mutex.synchronize { track_request(request_id) } sleep(TRACK_SLEEP) end end |
#start ⇒ Object
Start tracking
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/diffend/track.rb', line 20 def start response = Diffend::Execute.call(@config) perform(response['id']) rescue Diffend::Errors::HandledException sleep(RETRY_SLEEP) retry rescue StandardError => e Diffend::HandleErrors::Report.call( exception: e, config: @config, message: :unhandled_exception, report: true, raise_exception: false ) sleep(RETRY_SLEEP) retry end |