Sha256: 321a64cffc5683228d536abcb1719e7cd697ad4d646ff50b3c2c2a6082810064

Contents?: true

Size: 729 Bytes

Versions: 4

Compression:

Stored size: 729 Bytes

Contents

module Sentry
  class Transport
    class State
      def initialize
        reset
      end

      def should_try?
        return true if @status == :online

        interval = @retry_after || [@retry_number, 6].min**2
        return true if Sentry.utc_now - @last_check >= interval

        false
      end

      def failure(retry_after = nil)
        @status = :error
        @retry_number += 1
        @last_check = Sentry.utc_now
        @retry_after = retry_after
      end

      def success
        reset
      end

      def reset
        @status = :online
        @retry_number = 0
        @last_check = nil
        @retry_after = nil
      end

      def failed?
        @status == :error
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sentry-ruby-4.0.1 lib/sentry/transport/state.rb
sentry-ruby-4.0.0 lib/sentry/transport/state.rb
sentry-ruby-0.3.0 lib/sentry/transport/state.rb
sentry-ruby-0.2.0 lib/sentry/transport/state.rb