Added conductor

parent 9c103dde
defmodule Grengine.Conductor do
use GenServer
require Logger
def start_link, do: GenServer.start_link(__MODULE__, 1000, name: __MODULE__)
def init(state) do
tick()
{:ok, state}
end
defp tick, do: Process.send_after(self(), :tick, state)
def handle_info(:tick, state) do
Logger.info("handle tick")
get_performances
|> Enum.each fn perf ->
do_performance(perf)
end
tick()
{:noreply, state)
end
def get_performances do
# see https://github.com/paulanthonywilson/gproc_select_examples/blob/master/test/gproc_select_test.exs
matcher = :ets.fun2ms(fn x -> x end)
:gproc.select(matcher)
end
def do_performance(perf) do
Logger.info(perf)
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment