hello i am having a problem with creating supervisors, basically i want a sup to run in a loop until killed im trying to emulate live customers hitting my site and pushing random data to the channel and endpoints i get an error what am i doing wrong thanks
** (EXIT from #PID<0.643.0>) shutdown: failed to start child: Bot.Customer
** (EXIT) an exception was raised:
** (UndefinedFunctionError) function Bot.Customer.start_link/1 is undefined or private. Did you mean one of:
* start_link/0
(broker) Bot.Customer.start_link(Bot.Customer)
(stdlib) supervisor.erl:365: :supervisor.do_start_child/2
(stdlib) supervisor.erl:348: :supervisor.start_children/3
(stdlib) supervisor.erl:314: :supervisor.init_children/2
(stdlib) gen_server.erl:328: :gen_server.init_it/6
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
lib/bot/supervisor.ex
defmodule Bot.Supervisor do
use Supervisor
def start_link do
Supervisor.start_link(__MODULE__, :ok)
end
def init(:ok) do
children = [
worker(Bot.Customer, [Bot.Customer])
]
IO.inspect(children, label: "supervisor children")
supervise(children, strategy: :one_for_one)
end
end
defmodule Bot.Customer do
use GenServer
def generate() do
uuid = UUID.uuid1()
citys = ["Peoria","Glendale", "Tucson"]
states = ["AZ","NM","TX"]
zips = ["85711","85008","85710"]
streets = ["West Peoria Avenue","East Peoria Avenue","North Erlang Avenue", "West Elixir Blvd"]
:random.seed(:erlang.now)
faddress = Enum.random(5200..150000)
fcity = Enum.random(citys)
fstate = Enum.random(states)
fzip = Enum.random(zips)
fstreet = Enum.random(streets)
:random.seed(:erlang.now)
taddress = Enum.random(5200..150000)
tcity = Enum.random(citys)
tstate = Enum.random(states)
tzip = Enum.random(zips)
tstreet = Enum.random(streets)
from = to_string(faddress) <> " " <> to_string(fstreet) <> ", " <> to_string(fcity) <> ", " <> to_string(fstate) <>", United States"
to = to_string(taddress) <> " " <> to_string(tstreet) <> ", " <> to_string(tcity) <> ", " <> to_string(tstate) <>", United States"
%{from: from, to: to }
## connect to channels tbd
## store to db tbd
end
@doc """
Starts the registry with the given `name`.
"""
def start_link() do
GenServer.start_link(__MODULE__, :ok)
end
def handle_call({:get, slug}, _from, state) do
end
def handle_call({:set, slug, value}, _from, state) do
end
def init(args) do
end
end