Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapter configuration #30

Open
sdogruyol opened this issue Nov 5, 2015 · 6 comments
Open

Adapter configuration #30

sdogruyol opened this issue Nov 5, 2015 · 6 comments

Comments

@sdogruyol
Copy link
Contributor

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

@alex-fedorov
Copy link

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.

@alex-fedorov
Copy link

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"

@alex-fedorov
Copy link

maybe config file name can be more specific: config/active_record.yml

@alex-fedorov
Copy link

Maybe it would be nice to junk in different environments:

override_prefix: MYAPP

environments:
  development:
    adapters:
      postgres:
        # ...

@alex-fedorov
Copy link

Or maybe just have different names for files, like Elixir does:

  • config/active_record.yml - default config
  • config/development/active_record.yml - development config
  • config/test/active_record.yml - test config
  • config/production/active_record.yml - production config

@sdogruyol
Copy link
Contributor Author

I prefer the AR style

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants