Class: MailRoom::MicrosoftGraph::Connection
- Inherits:
-
Connection
- Object
- Connection
- MailRoom::MicrosoftGraph::Connection
- Defined in:
- lib/mail_room/microsoft_graph/connection.rb
Constant Summary collapse
- SCOPE =
'https://graph.microsoft.com/.default'
- 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
Constructor Details
#initialize(mailbox) ⇒ Connection
Returns a new instance of Connection.
17 18 19 20 21 22 |
# File 'lib/mail_room/microsoft_graph/connection.rb', line 17 def initialize(mailbox) super reset setup end |
Instance Attribute Details
#throttled_count ⇒ Object
Returns the value of attribute throttled_count.
15 16 17 |
# File 'lib/mail_room/microsoft_graph/connection.rb', line 15 def throttled_count @throttled_count end |
#token ⇒ Object
Returns the value of attribute token.
15 16 17 |
# File 'lib/mail_room/microsoft_graph/connection.rb', line 15 def token @token end |
Instance Method Details
#wait ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mail_room/microsoft_graph/connection.rb', line 24 def wait 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 |