Even though many plugs are stateless, some need to keep state for latter use, such as plugs dealing with sessions or rate limiting.
Then it is in some cases needed to initialize a store (ETS, mnesia, setting up a pool for Memcached, Riak, …). I see three options to do that:
- Checking if the store exists when calling the
call()callback, and if it doesn’t, create it (seems costly in terms of performances)
- Make the plug an application, and deal with store initialization in the
- Do nothing and expect the store to be already set up somewhere else. It seems that’s the approach with Plug.Session.ETS (but is that the rule ? This store is for dev purpose)
Shall plugs remain stateless? What’s the best practices? Any pointer is welcome
Have a great day!