Class: Bleib::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/bleib/database.rb

Overview

Finds out if a database is running and accessible.

Does so by using ActiveRecord without a booted rails environment (because a non-accessible database can cause the bootup to fail).

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Database

Returns a new instance of Database.



8
9
10
# File 'lib/bleib/database.rb', line 8

def initialize(configuration)
  @configuration = configuration
end

Instance Method Details

#wait_for_connectionObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/bleib/database.rb', line 12

def wait_for_connection
  logger.info('Waiting for connection to database')

  wait while database_down?

  logger.info('Connection to database established')

  # Nobody else shall use our single-connection pool.
  remove_connection
end