1. Absolutely block. Everywhere it makes sense. Use this to serialise stuff (e.g. if I send a ping I want to wait for a pong before I send a different message). Take advantage of the fact that you've separate things into a process (Elixir term - green thread/fibre) for each task, e.g. each connection to a different node is its own process.
2. You can absolutely just use timeouts, but there are a few ways of doing it depending on context. Operating things as a state-machine is usually the clearest way to do things and if you get the event "timeout" before you get the event "response" (or similar) you can handle all that very clearly.
3. Yup, good advice. In Elixir this is also about separating pure functional code, from the 'process machinery' that runs it. Mostly because pure functional code is easier to test!
rkangel 2021-08-19 15:30:34 +0000 UTC [ - ]
1. Absolutely block. Everywhere it makes sense. Use this to serialise stuff (e.g. if I send a ping I want to wait for a pong before I send a different message). Take advantage of the fact that you've separate things into a process (Elixir term - green thread/fibre) for each task, e.g. each connection to a different node is its own process.
2. You can absolutely just use timeouts, but there are a few ways of doing it depending on context. Operating things as a state-machine is usually the clearest way to do things and if you get the event "timeout" before you get the event "response" (or similar) you can handle all that very clearly.
3. Yup, good advice. In Elixir this is also about separating pure functional code, from the 'process machinery' that runs it. Mostly because pure functional code is easier to test!