Files
chess-endgame-trainer/lib/chesstrainer/application.ex
T
owenrees a5bb1cb670 Scale the tablebase cache to ~100k entries (#24)
* Slim the cached tablebase value to the fields the trainer reads (#20)

* Sample for LFU eviction instead of scanning the cache (#21)

* Make cache size configurable and back up daily off-peak (#22)

* Document the cache design in the glossary and an ADR (#23)

* Address cache-scaling code review findings
2026-11-02 23:02:01 +01:00

40 lines
1.3 KiB
Elixir

defmodule Chesstrainer.Application do
# See https://elixir.hexdocs.pm/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
@impl true
def start(_type, _args) do
cache_opts = Application.get_env(:chesstrainer, Chesstrainer.Cache, [])
children = [
ChesstrainerWeb.Telemetry,
Chesstrainer.Repo,
{DNSCluster, query: Application.get_env(:chesstrainer, :dns_cluster_query) || :ignore},
{Phoenix.PubSub, name: Chesstrainer.PubSub},
# Start a worker by calling: Chesstrainer.Worker.start_link(arg)
# {Chesstrainer.Worker, arg},
# Start to serve requests, typically the last entry
ChesstrainerWeb.Endpoint,
{Registry, keys: :unique, name: Chesstrainer.CacheRegistry},
{Task.Supervisor, name: Chesstrainer.Cache.BackupSupervisor},
{Chesstrainer.Cache, {:tablebase, cache_opts}}
]
# See https://elixir.hexdocs.pm/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Chesstrainer.Supervisor]
Supervisor.start_link(children, opts)
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
@impl true
def config_change(changed, _new, removed) do
ChesstrainerWeb.Endpoint.config_change(changed, removed)
:ok
end
end