I have a GenStage and all I’m trying to do is spawn a process inside handle_events. Ultimately I want handle_events to return [] and then via message passing of the spawn() handle sending the events myself when they complete
def handle_events(users, _from, state) do
endpoints = Config.get()[:endpoints]
for user <- users do
spawn(fn (user) -> do_user_bidding(user, endpoints) end)
end
{:noreply, [], state}
end
The error I get is
handle_events/3> with arity 1 called with no arguments
19:50:14.411 [error] Task #PID<0.365.0> started from #PID<0.318.0> terminating
** (BadArityError) #Function<4.86334033/1 in MyApp.EndpointAggregator.do_user_bidding/2> with arity 1 called with no arguments
:erlang.apply/2
(elixir) lib/task/supervised.ex:89: Task.Supervised.do_apply/2
(elixir) lib/task/supervised.ex:38: Task.Supervised.reply/5
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Function: &:erlang.apply/2
Args: [#Function<4.86334033/1 in MyApp.EndpointAggregator.do_user_bidding/2>, []]
ugh crap… so that first problem you had me fix was the actual problem. I thought that was the ‘fixed’ way but it turns out I broke it. You helped me fix it, and now the broken code is in the function being called (I use tasks inside that do_user_bidding function)