Class: Imap::Backup::Account::ClientFactory

Inherits:
Object
  • Object
show all
Includes:
RetryOnError
Defined in:
lib/imap/backup/account/client_factory.rb

Constant Summary collapse

LOGIN_RETRY_CLASSES =
[::EOFError, ::Errno::ECONNRESET, ::SocketError].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RetryOnError

#retry_on_error

Constructor Details

#initialize(account:) ⇒ ClientFactory

Returns a new instance of ClientFactory.



20
21
22
23
24
# File 'lib/imap/backup/account/client_factory.rb', line 20

def initialize(account:)
  @account = 
  @provider = nil
  @server = nil
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



18
19
20
# File 'lib/imap/backup/account/client_factory.rb', line 18

def 
  @account
end

Instance Method Details

#runObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/imap/backup/account/client_factory.rb', line 26

def run
  retry_on_error(errors: LOGIN_RETRY_CLASSES) do
    options = provider_options
    Logger.logger.debug(
      "Creating IMAP instance: #{server}, options: #{options.inspect}"
    )
    client =
      if provider.is_a?(Email::Provider::AppleMail)
        Client::AppleMail.new(server, , options)
      else
        Client::Default.new(server, , options)
      end
    client.
    client
  end
end