class Diffend::Track
Track
what is run in production
Constants
- RETRY_SLEEP
Time that we want to wait before we retry
- TRACK_SLEEP
Time that we want to wait between track requests
Public Class Methods
new(config)
click to toggle source
Initialize tracking
@param config [Diffend::Config]
# File lib/diffend/track.rb, line 14 def initialize(config) @mutex = Mutex.new @config = config end
Public Instance Methods
build_request_object(request_id)
click to toggle source
@param request_id [String]
@return [Diffend::RequestObject]
# 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)
click to toggle source
@param request_id [String]
# 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()
click to toggle source
Start tracking
# 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
track_request(request_id)
click to toggle source
Perform a track request
@param request_id [String]
# File lib/diffend/track.rb, line 54 def track_request(request_id) Diffend::Request.call( build_request_object(request_id) ) end