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

feat(db): support additional connection details #266

Merged
merged 2 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ shards:

active-model:
git: https://github.com/spider-gazelle/active-model.git
version: 4.2.3
version: 4.3.0

admiral:
git: https://github.com/jwaldrip/admiral.cr.git
version: 1.12.1

ameba:
git: https://github.com/veelenga/ameba.git
version: 1.4.2
version: 1.4.3

any_hash:
git: https://github.com/sija/any_hash.cr.git
Expand Down Expand Up @@ -65,6 +65,10 @@ shards:
git: https://github.com/arcage/crystal-email.git
version: 0.7.0

eventbus:
git: https://github.com/spider-gazelle/eventbus.git
version: 0.9.9+git.commit.086b2ba92475b88e8481b0387eb56c735cbfd7bd

exception_page:
git: https://github.com/crystal-loot/exception_page.git
version: 0.3.0
Expand Down Expand Up @@ -115,7 +119,7 @@ shards:

lucky_router:
git: https://github.com/luckyframework/lucky_router.git
version: 0.5.1
version: 0.5.2

nbchannel:
git: https://github.com/wyhaines/nbchannel.cr.git
Expand Down Expand Up @@ -165,6 +169,10 @@ shards:
git: https://github.com/will/crystal-pg.git
version: 0.26.0

pg-orm:
git: https://github.com/spider-gazelle/pg-orm.git
version: 1.0.0+git.commit.2bbafec9579f175880281279d33168360176540c

place_calendar:
git: https://github.com/placeos/calendar.git
version: 4.15.7
Expand All @@ -179,7 +187,11 @@ shards:

placeos-models:
git: https://github.com/placeos/models.git
version: 8.13.3
version: 9.0.1

pool:
git: https://github.com/ysbaddaden/pool.git
version: 0.3.0

promise:
git: https://github.com/spider-gazelle/promise.git
Expand All @@ -193,13 +205,9 @@ shards:
git: https://github.com/sija/raven.cr.git
version: 1.9.3+git.commit.f328bfdafe335f31e476c275fd434ac16049adea

rethinkdb:
git: https://github.com/kingsleyh/crystal-rethinkdb.git
version: 0.3.1

rethinkdb-orm:
git: https://github.com/spider-gazelle/rethinkdb-orm.git
version: 6.0.4
redis:
git: https://github.com/stefanwille/crystal-redis.git
version: 2.9.0

retriable:
git: https://github.com/sija/retriable.cr.git
Expand Down
16 changes: 15 additions & 1 deletion src/constants.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require "uri"

module App
NAME = "staff-api"
{% begin %}
Expand All @@ -21,7 +23,19 @@ module App
Log = ::Log.for(NAME)
LOG_BACKEND = ActionController.default_backend

PG_DATABASE_URL = TEST ? ENV["PG_TEST_DATABASE_URL"] : ENV["PG_DATABASE_URL"]
PG_DATABASE_URL = if url = TEST ? ENV["PG_TEST_DATABASE_URL"]? : ENV["PG_DATABASE_URL"]?
url
else
pg_host = ENV["PG_HOST"]? || "postgres"
pg_port = (ENV["PG_PORT"]? || 5432).to_i
pg_path = "/" + (ENV["PG_DB"]? || ENV["PG_DATABASE"])
pg_user = ENV["PG_USER"]? || "postgres"
pg_pass = ENV["PG_PASSWORD"]? || ""
pgquery = ENV["PG_QUERY"]?

URI.new("postgresql", pg_host, pg_port, pg_path, pgquery, pg_user, pg_pass).to_s
end

PG_CONNECTION_POOL_SIZE = ENV["PG_CONNECTION_POOL_SIZE"]?.presence.try(&.to_i?) || 5

PLACE_URI = ENV["PLACE_URI"]?.presence || abort("PLACE_URI not in environment")
Expand Down