Class: MailRoom::MicrosoftGraph::Connection
- Inherits:
-
Connection
- Object
- Connection
- MailRoom::MicrosoftGraph::Connection
- Defined in:
- lib/mail_room/microsoft_graph/connection.rb
Constant Summary collapse
- NEXT_PAGE_KEY =
'@odata.nextLink'
- DEFAULT_POLL_INTERVAL_S =
60
- TooManyRequestsError =
Class.new(RuntimeError)
Instance Attribute Summary collapse
-
#throttled_count ⇒ Object
Returns the value of attribute throttled_count.
-
#token ⇒ Object
Returns the value of attribute token.
Attributes inherited from Connection
#mailbox, #new_message_handler
Instance Method Summary collapse
-
#initialize(mailbox) ⇒ Connection
constructor
A new instance of Connection.
- #wait ⇒ Object
Methods inherited from Connection
#on_new_message, #quit, #stopped?
Constructor Details
#initialize(mailbox) ⇒ Connection
Returns a new instance of Connection.
16 17 18 19 20 21 |
# File 'lib/mail_room/microsoft_graph/connection.rb', line 16 def initialize(mailbox) super reset setup end |
Instance Attribute Details
#throttled_count ⇒ Object
Returns the value of attribute throttled_count.
14 15 16 |
# File 'lib/mail_room/microsoft_graph/connection.rb', line 14 def throttled_count @throttled_count end |
#token ⇒ Object
Returns the value of attribute token.
14 15 16 |
# File 'lib/mail_room/microsoft_graph/connection.rb', line 14 def token @token end |
Instance Method Details
#wait ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mail_room/microsoft_graph/connection.rb', line 23 def wait return if stopped? process_mailbox @throttled_count = 0 rescue TooManyRequestsError => e @throttled_count += 1 @mailbox.logger.warn({ context: @mailbox.context, action: 'Too many requests, backing off...', backoff_s: backoff_secs, error: e., error_backtrace: e.backtrace }) backoff rescue IOError => e @mailbox.logger.warn({ context: @mailbox.context, action: 'Disconnected. Resetting...', error: e., error_backtrace: e.backtrace }) reset setup end |