4
votes

I need to setup a background worker in Phoenix and communicate with it from a channel through Elixir send/receive.

  1. Where should I put a module for the working in the Phoenix dir structure (lib perhaps?)
  2. How do I Load/Reference the module from channels?
1

1 Answers

5
votes
  1. I think it depends on count of these modules. If you have only one, you could put it to lib directly. If there are many workers modules, I'd prefer put them to lib/workers or even to workers. In the latter case you should list workers folder in elixirc_paths function inside mix.exs.
  2. Nothing special. All modules placed inside folders mentioned in elixirc_paths will be loaded automatically.