Exception: Legion::Extensions::MicrosoftTeams::Errors::Throttled

Inherits:
StandardError
  • Object
show all
Defined in:
lib/legion/extensions/microsoft_teams/errors.rb

Overview

Raised when Microsoft Graph (or the Bot Framework) throttles the caller and the retry policy has been exhausted, or when an actor wants to surface a throttle event without retrying further.

‘retry_after` carries the last advertised Retry-After interval (in seconds) as parsed from the upstream header. **It is nil when the server returned no Retry-After header or one we could not parse** — callers must check `retry_after_known?` before treating the value as a server directive. Conflating “header missing” with “retry immediately” was the bug the original fleet outage exposed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, retry_after: nil, request: nil, attempts: nil) ⇒ Throttled

Returns a new instance of Throttled.

Parameters:

  • status (Integer)

    the upstream HTTP status (e.g. 429)

  • retry_after (Float, Integer, nil) (defaults to: nil)

    seconds the server advised waiting, or nil if the header was absent/unparseable

  • request (String, nil) (defaults to: nil)

    the path or URL that was throttled

  • attempts (Integer, nil) (defaults to: nil)

    how many retries the middleware tried before giving up; nil means “not tracked”



26
27
28
29
30
31
32
# File 'lib/legion/extensions/microsoft_teams/errors.rb', line 26

def initialize(status:, retry_after: nil, request: nil, attempts: nil)
  @status      = coerce_status(status)
  @retry_after = coerce_retry_after(retry_after)
  @request     = request
  @attempts    = attempts.nil? ? nil : Integer(attempts)
  super(build_message)
end

Instance Attribute Details

#attemptsObject (readonly)

Returns the value of attribute attempts.



18
19
20
# File 'lib/legion/extensions/microsoft_teams/errors.rb', line 18

def attempts
  @attempts
end

#requestObject (readonly)

Returns the value of attribute request.



18
19
20
# File 'lib/legion/extensions/microsoft_teams/errors.rb', line 18

def request
  @request
end

#retry_afterObject (readonly)

Returns the value of attribute retry_after.



18
19
20
# File 'lib/legion/extensions/microsoft_teams/errors.rb', line 18

def retry_after
  @retry_after
end

#statusObject (readonly)

Returns the value of attribute status.



18
19
20
# File 'lib/legion/extensions/microsoft_teams/errors.rb', line 18

def status
  @status
end

Instance Method Details

#retry_after_known?Boolean

Returns true when the upstream advised a specific wait interval; false when the header was missing or unparseable. Use this to decide whether to honor the wait verbatim or apply a local policy default before re-scheduling.

Returns:

  • (Boolean)

    true when the upstream advised a specific wait interval; false when the header was missing or unparseable. Use this to decide whether to honor the wait verbatim or apply a local policy default before re-scheduling.



38
39
40
# File 'lib/legion/extensions/microsoft_teams/errors.rb', line 38

def retry_after_known?
  !@retry_after.nil?
end