`Boruta.Cache` is started even when another `cache_backend` is configured
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start at Boruta.Application.start/2 in lib/boruta/application.ex and inspect how Boruta.Config.cache_backend() selects the cache. Verify the application restart behavior with the new backend configuration, then update the Boruta.Config moduledoc and CHANGELOG as described; done means the configured alternative backend does not start Boruta.Cache while the default still does.
Written by the indexing model from the issue text.
Description
What is wrong
Boruta.Application.start/2 always starts Boruta.Cache (lib/boruta/application.ex on v2-3, unchanged on master):
children = [
Boruta.Cache,
{Finch, name: OpenIDHttpClient}
]
The cache_backend option exists so that a host application can bring its own backend, and the library honours it everywhere it caches: Boruta.Ecto.ClientStore, Boruta.Ecto.ScopeStore and Boruta.Ecto.TokenStore only ever call Boruta.Config.cache_backend(), and nothing else references Boruta.Cache. With another backend configured the Nebulex cache is therefore started, supervised and replicated for no caller.
What it costs
Boruta.Cache is a Nebulex.Adapters.Replicated cache. Started with a no-op cache_backend configured (Boruta 2.3.8, Nebulex 3.0.4, nebulex_distributed 3.2.3, OTP 29), its tree looks like this:
Processes under Boruta.Supervisor that belong to the cache |
34 (inbox and outbox partition buffers, their task supervisors, the cluster monitor, the primary cache) |
ETS tables named Boruta.Cache* |
38, about 588 KiB |
| Process heaps of the cache tree | about 333 KiB |
| Idle activity | about 3,200 reductions per 5 s (the partition buffers tick every second) |
Small in absolute terms, but on connected nodes the cluster monitor also joins the pg group and pushes a bootstrap of the (empty) cache to its peers on every start, and the host carries the nebulex, nebulex_local, nebulex_distributed, nebulex_streams, shards, ex_hash_ring and partitioned_buffer packages in its release for code it never calls.
Proposed fix (PR follows)
Start Boruta.Cache only when Boruta.Config.cache_backend() is Boruta.Cache. A host with another backend already has to start that backend itself, so nothing changes for it, and nothing changes for the default configuration. The PR adds the conditional in Boruta.Application, a sentence in the Boruta.Config moduledoc, a test that restarts the application with another backend, and a CHANGELOG entry. The patch applies unchanged to master.
Making nebulex an optional dependency, so that hosts with their own backend do not ship it at all, would be the next step; Boruta.Cache is defined with use Nebulex.Cache at compile time, so that is a separate change.
- Dominant language
- Elixir
- Stars
- 97
- Forks
- 23
- Avg merge
- 8d 6h
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from malach-it/boruta_auth
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
malach-it/boruta_auth#77 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
malach-it/boruta_auth#82 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 68/100
malach-it/boruta_auth#78 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
malach-it/boruta_auth#62 · 2 comments · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
malach-it/boruta_auth#47 · 8 comments ·
All issues in malach-it/boruta_auth
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
phoenixframework/phoenix#6847 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
beyond-all-reason/teiserver#1584 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ash-project/ash#2954 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
membraneframework/boombox#149 ·