-
Notifications
You must be signed in to change notification settings - Fork 79
/
config.exs
93 lines (74 loc) · 2.23 KB
/
config.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import Config
# config :fun_with_flags, :persistence,
# [adapter: FunWithFlags.Store.Persistent.Redis]
# config :fun_with_flags, :cache_bust_notifications,
# [enabled: true, adapter: FunWithFlags.Notifications.Redis]
# -------------------------------------------------
# Extract from the ENV
with_cache =
case System.get_env("CACHE_ENABLED") do
"false" -> false
"0" -> false
_ -> true # default
end
with_phx_pubsub =
case System.get_env("PUBSUB_BROKER") do
"phoenix_pubsub" -> true
_ -> false
end
with_ecto =
case System.get_env("PERSISTENCE") do
"ecto" -> true
_ -> false # default
end
# -------------------------------------------------
# Configuration
config :fun_with_flags, :cache,
enabled: with_cache,
ttl: 60
if with_phx_pubsub do
config :fun_with_flags, :cache_bust_notifications, [
adapter: FunWithFlags.Notifications.PhoenixPubSub,
client: :fwf_test
]
end
if with_ecto do
# this library's config
config :fun_with_flags, :persistence,
adapter: FunWithFlags.Store.Persistent.Ecto,
repo: FunWithFlags.Dev.EctoRepo
# To test the compile-time config warnings.
# config :fun_with_flags, :persistence,
# ecto_table_name: System.get_env("ECTO_TABLE_NAME", "fun_with_flags_toggles")
# ecto's config
config :fun_with_flags, ecto_repos: [FunWithFlags.Dev.EctoRepo]
config :fun_with_flags, FunWithFlags.Dev.EctoRepo,
database: "fun_with_flags_dev",
hostname: "localhost",
pool_size: 10
case System.get_env("RDBMS") do
"mysql" ->
mysql_password = case System.get_env("CI") do
"true" -> "root" # On GitHub Actions.
_ -> "" # For a default dev-insecure installation, e.g. via Homebrew on macOS.
end
config :fun_with_flags, FunWithFlags.Dev.EctoRepo,
username: "root",
password: mysql_password
"sqlite" ->
config :fun_with_flags, FunWithFlags.Dev.EctoRepo,
username: "sqlite",
password: "sqlite"
_ ->
config :fun_with_flags, FunWithFlags.Dev.EctoRepo,
username: "postgres",
password: "postgres"
end
end
# -------------------------------------------------
# Import
#
case config_env() do
:test -> import_config "test.exs"
_ -> nil
end