Agents and tasks in Elixir

Click for: original source

Vitaly Tatarintsev wrote article about messaging in Elixirlang. Elixir provides nice wrappers around processes such as Agents and Tasks. Agents allow us to keep a state and Tasks help us to run processes in parallel.

Agents are background processes which help us to maintain a state. The usage of an agent is pretty straightforward. We have the ability to spawn an agent with an initial value, update its state and read the state.

Tasks are processes which run in a background. With the Elixir tasks, we can run all these jobs in parallel and then collect the result (if we need it).

Article also sports code examples. Also look at the older article of the same author: the StatefulRobot example with more Elixir goodies.

Author encourages you to read the documentation about Agents and Tasks. You can find more useful functions there which can help you to solve different problems.

[Read More]

Tags software-architecture functional-programming programming