inaka/worker_pool

wpool:broadcast issue

Closed this issue · 10 comments

Very sorry to post so many questions :) -- I use wpool:start_sup_pool, and I want to broadcast a command for all workers to work, however while calling: wpool:broadcast, I get the following error:

Im thinking broadcast is not defined:
{undef,[{wpool,broadcast, ...

wpool:call, and wpool:cast work!

You're probably not using the latest version of wpool ;) - can you confirm you're using 3.0.0?

Yes: #124 (comment)

Also: worker_pool/ebin/worker_pool.app -> {vsn,"3.0.0"},

OK, then… can you paste the whole error here, please?

I just tested and made sure both of these work:

wpool:call(listen_worker, {test})
wpool:cast(listen_worker, {test})
(output)
listen_worker:handle_call {test} -> PID[<0.121.0>]
listen_worker:handle_cast {test} -> PID[<0.121.0>]

wpool:broadcast(listen_worker, {test})
(output)
{undef,[{wpool,broadcast,[listen_worker,{test}],[]},
{listen,init,0,[{file,"listen.erl"},{line,28}]},
{chat_app,init,0,[{file,"chat_app.erl"},{line,23}]}]}

Edit: Because I am very new to Erlang, and not very experienced, maybe make a test project to test yourself. There is a high chance this is on my end ...

If it helps, I am using IntelliJ, with https://github.com/ignatov/intellij-erlang on Windows 10 64bit, and there were some hickups on windows environment (have to set my own flags):

-pa D:\Erlang-Workspace\Chat\deps\worker_pool\ebin

Maybe this is related to this somehow?

So, it's not released yet! @Euen any plans for releasing a new version of wpool soon?

In the meantime, is there anyway I can hack it to cast for each worker?

EDIT: I guess the following would be okay until the new feature is available:

% HACK
cast_listen(0, _Name, _Args) ->
{ok};
cast_listen(_Counter, _Name, _Args) ->
wpool:cast(_Name, _Args),
cast_listen(_Counter-1, _Name, _Args).

Euen commented

You already can find the release in hex.pm https://hex.pm/packages/worker_pool/3.1.0 @JrIndie @elbrujohalcon 👍