Erlang handle_call 周り
gen_server:handle_call で State を持ち回る事での状態を保持する事ができる。
handle_call(get, From, State) -> {reply, {State#state.key, State#state.value}, {state, State#state.key, myValue2, State#state.left, State#state.right}};
gen_server:start_link で引数を取る。
gen_server:start_link({local, ?SERVER}, ?MODULE, Args, []).
今やりたいのは handle_call で特定のメッセージを受けたときに node プロセスを立ち上げる事。
その際にせっかくなので supervisor の管理下に入れるために、supervisor:start_child で process 起動。
Pid = supervisor:start_child(mio_sup, {mio_node, {mio_node, start_link, [[myKey, myValue]]}, permanent, brutal_kill, worker, [mio_node]}),
これがうまく行かない。
Pid={error,{already_started,<0.68.0>}}
mio_node モジュールで定義したサーバーを無名でたくさん起動し、かつ supervisor 管理下におくにはどうしたら良いんだろう。