beyond-all-reason / teiserver

Middleware server for online gaming
https://www.beyondallreason.info/
MIT License
55 stars 53 forks source link

Move cache initialisation under supervision trees #291

Closed geekingfrog closed 2 months ago

geekingfrog commented 4 months ago

This PR moves the caching logic into logically independent modules, and define supervision tree to start the caches and do initialisation at the same time.

The main benefit is defining a cache and warming it up is now in one place instead of spread across the application.ex and startup.ex files.

One thing to note: some caches are used together. For example config_site_type_store and :config_site_cache are both used by add_site_config_type. In this case, the restart strategy should be :one_for_all so that if a cache dies, the other is also terminated, and then both are restarted before initialisation.

This should be reviewed commit by commit where I tried to only move small bits at a time.

Ultimately I want to straighten up the startup logic which has a bunch of init code outside supervision trees, but that'll come later.

How to test that?

There shouldn't be any functional changes, so:

Teifion commented 3 months ago

This is a really sensible idea; I'll be implementing it in my other projects. Thank you :)

L-e-x-o-n commented 2 months ago

Works on integration server.