Created
September 15, 2016 16:32
-
-
Save alvises/7f5329ac9bfe0c0803de4a0c7d97b91e to your computer and use it in GitHub Desktop.
supervised genstage, producer, producer_consumer, consumer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:ok, p} = Producer.start_link | |
workers_num = 20 | |
workers = Enum.map(1..workers_num, fn (n)-> | |
worker(ProducerConsumer, [worker_name(n)], id: n) | |
end) | |
worker_names = Enum.map 1..8, &worker_name/1 | |
#consumer subscribes to the producer names passed | |
consumers = [worker(Consumer, [worker_names])] | |
children = workers ++ consumers | |
Supervisor.start_link children, strategy: :rest_for_one |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment