Это швы erlang только посылает забавные ссылки на удаленные узлы. при попытке отправить закрытие, он, по-видимому, закрывает закрытие в вызывающем модуле и отправляет забавную ссылку на это встроенное удовольствие удалённому узлу. Вот тест:Есть ли способ отправить закрытие удаленного узла в erlang?
-module(funserver).
-compile(export_all).
loop()->
receive {From, ping} ->
error_logger:info_msg("received ping from ~p~n", [From]),
From ! pong,
loop();
{From, Fun} when is_function(Fun) ->
error_logger:info_msg("executing function ~p received from ~p~n", [Fun, From]),
From ! Fun(),
loop();
M ->
error_logger:error_msg("received ~p, don't know what to do with it", [M])
end.
и тест на узле клиента:
test_remote_node_can_execute_sent_clojure()->
{ok, ModName, Binary} = compile:file(funserver, [verbose,report_errors,report_warnings, binary]),
{module, ModName} = rpc:call(?other_node, code, load_binary, [ModName, atom_to_list(ModName), Binary]),
Pid = spawn(?other_node, funserver, loop, []),
OutVar = {"token with love from", node()},
Pid ! {self(), fun()-> {OutVar, erlang:node()} end},
receive Result ->
Result = {OutVar, node(Pid)}
after 300 ->
timeout
end.
получение
Error in process <7162.123.0> on node [email protected] with exit value:
{undef,[{#Fun<tests.1.127565388>,[],[]},
{funserver,loop,0,[{file,"funserver.erl"},{line,12}]}]}
timeout
Так может Clojure быть отправлен на удаленный узел?
Разве это не было подробно обсуждено в [этой теме] (http://erlang.org/pipermail/erlang-questions/2016-September/090046.html) в списке рассылки erlang-questions? –
Возможный дубликат [Что такое пункт Spawn (Node, Fun) на erlang, если Node должен иметь тот же модуль, который можно загрузить как клиентский узел?] (Http://stackoverflow.com/questions/39255471/what-is -The-точка-в-spawnnode-весело-на-Эрл-если-узла имеет к у-The-же-мо) – mpm