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.



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

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

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



16
17
18
# File 'lib/imap/backup/account/client_factory.rb', line 16

def 
  @account
end

Instance Method Details

#runObject



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

def run
  retry_on_error(errors: ) 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