elixir - OTP: Start GenEvent under Supervisor With Name -


i'm trying create genevent process specific name (for question, i'm going {:global, :x}). if create genevent normally, e.g. genevent.start_link([name: {:global, :x}]), can access genevent @ name. that's good. want create genevent under supervision tree. this, put genevent supervision.spec worker spec., , that's when things blow up.

iex(1)> {:ok, sup} = supervisor.start_link([], strategy: :one_for_one) {:ok, #pid<0.127.0>} iex(2)> supervisor.start_child(sup, supervisor.spec.worker(genevent, [name: {:global, :x}], [])) {:error,  {{:exit,                                                                                                                                                                                        {:function_clause,                                                                                                                                                                             [{genevent, :start_link, [name: {:global, :x}],                                                                                                                                                 [file: 'lib/gen_event.ex', line: 358]},                                                                                                                                                      {:supervisor, :do_start_child, 2, [file: 'supervisor.erl', line: 343]},                                                                                                                       {:supervisor, :handle_start_child, 2, [file: 'supervisor.erl', line: 715]},                                                                                                                   {:supervisor, :handle_call, 3, [file: 'supervisor.erl', line: 400]},                                                                                                                          {:gen_server, :try_handle_call, 4, [file: 'gen_server.erl', line: 629]},                                                                                                                      {:gen_server, :handle_msg, 5, [file: 'gen_server.erl', line: 661]},      {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 239]}]}},   {:child, :undefined, genevent, {genevent, :start_link, [name: {:global, :x}]},    :permanent, 5000, :worker, :dynamic}}} 

what doing wrong?

(this answer comes asonge in #elixir on irc.freenode.net. thanks!)

the args value supervisor.spec.worker function takes list of arguments pass function. genevent.start_link\1, takes single argument list. such, need pass list containing 1 element (the args array start_link) list wanted start_link. such, call worker supervisor.spec.worker(genevent, [[name: {:global, :x}]], []).


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -