Adapter configuration
We need to have a way to configure the underlying adapter. This is needed for
- Setting connection url, user, password, host e.g
- Timeout options
- Pool options
WDYT @waterlink
Yeah of course! I expect this list to be waaay longer in the future :)
I would love to have similar configuration to the ruby's AR - through config/database.yml or something.
Though it would be nice to leave an option for 12factor. I.e.: there should be still a possibility to configure everything through environment variables, that are in certain format.
For example, given this config/database.yml file:
override_prefix: MYAPP
adapters:
postgres:
username: john
password: welcome
hostname: 127.0.0.1
port: 5432
timeout: 5000 # ms
pool: 10
You can for example override hostname with: export MYAPP_ADAPTERS_POSTGRES_HOSTNAME=db.production01.internal.myapp.com and so on.
Implementation for this should probably sit within active_record.cr codebase. And it should expose some simple integration API for querying, along the lines:
ActiveRecord::Config.adapters.postgres.encoding? || "utf8"
maybe config file name can be more specific: config/active_record.yml
Maybe it would be nice to junk in different environments:
override_prefix: MYAPP
environments:
development:
adapters:
postgres:
# ...
Or maybe just have different names for files, like Elixir does:
config/active_record.yml- default configconfig/development/active_record.yml- development configconfig/test/active_record.yml- test configconfig/production/active_record.yml- production config
I prefer the AR style