When are Agent and Task.Supervisor useful?

AFAIK Agent is a “type” of GenServer created specifically for storing “shared” state, since in Elixir everything is isolated, I guess one would use it for storing live, quickly updating information.
Task.Supervisor can be used as a worker and it was designed to supervise Tasks, if you don’t want them to be linked to another process and you want to define different strategy. I’m personally using it for sending email messages or push notifications, basically the activity which is not critical for the business logic and can be run in background.

3 Likes