Method: Jets::Booter.connect_db

Defined in:
lib/jets/booter.rb

.connect_dbObject

Eager connect to database, so connections are established in the Lambda Execution Context and get reused. Interestingly, the connections info is stored in the shared state but the connection doesnt show up on ‘show processlist` until after a query. Have confirmed that the connection is reused and the connection count stays the same.



97
98
99
100
101
102
103
# File 'lib/jets/booter.rb', line 97

def connect_db
  primary_hash_config = ActiveRecord::Base.configurations.configs_for(env_name: Jets.env).find { |hash_config|
    hash_config.spec_name == "primary"
  }
  primary_config = primary_hash_config.config # config is a normal Ruby Hash
  ActiveRecord::Base.establish_connection(primary_config)
end