summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre de Lacroix <pierre@pdelacroix.com>2020-12-09 11:14:43 +0100
committerPierre de Lacroix <pierre@pdelacroix.com>2020-12-09 11:14:43 +0100
commit36322732a101c9b4c6ce214c097cab47cce017c9 (patch)
tree58b3503a5eacda6eedbc47e1a5a435349d6ee168
parentadd bridge context (diff)
dont' start the repo unless necessary
-rw-r--r--config/test.exs1
-rw-r--r--lib/matrix_app_service/application.ex24
2 files changed, 17 insertions, 8 deletions
diff --git a/config/test.exs b/config/test.exs
index 1402cf0..c9fbbd4 100644
--- a/config/test.exs
+++ b/config/test.exs
@@ -23,6 +23,7 @@ config :logger, level: :warn
config :matrix_app_service,
internal_supervisor: true,
+ internal_repo: true,
transaction_adapter: MatrixAppService.TestTransactionAdapter,
room_adapter: MatrixAppService.TestRoomAdapter,
user_adapter: MatrixAppService.TestUserAdapter,
diff --git a/lib/matrix_app_service/application.ex b/lib/matrix_app_service/application.ex
index ae935eb..408d5ab 100644
--- a/lib/matrix_app_service/application.ex
+++ b/lib/matrix_app_service/application.ex
@@ -18,16 +18,20 @@ defmodule MatrixAppService.Application do
]
children =
- if start_endpoint?() do
- [
- # MatrixAppServiceWeb.Endpoint
- {MatrixAppServiceWeb.Endpoint, endpoint_config()},
+ if start_endpoint?(),
+ do: [
+ {MatrixAppServiceWeb.Endpoint, endpoint_config()}
+ | children
+ ],
+ else: children
+
+ children =
+ if start_repo?(),
+ do: [
MatrixAppService.Repo
| children
- ]
- else
- children
- end
+ ],
+ else: children
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
@@ -49,6 +53,10 @@ defmodule MatrixAppService.Application do
Application.get_env(:matrix_app_service, :internal_supervisor, false)
end
+ def start_repo?() do
+ Application.get_env(:matrix_app_service, :internal_repo, false)
+ end
+
def endpoint_config() do
[
transaction_adapter: Application.fetch_env!(:matrix_app_service, :transaction_adapter),