[erlang-questions] spawning funs on other nodes that does not contain my module

Lukas Larsson garazdawi@REDACTED
Tue Nov 30 21:31:04 CET 2010


It is not possible directly, you would have to get the code to the other
side somehow. code:load_binary is made specifically for this purpose,

http://erlang.org/doc/man/code.html#load_binary-3

Just use rpc:call(MyNode,
code,load_binary,[mymod,"mymod.erl",BinaryModuleCode]) and off you go!

Lukas

On Tue, Nov 30, 2010 at 7:36 PM, Marcel Meyer <marcel.meyer@REDACTED>wrote:

> Hi there,
>
> Is it possible to spawn a function (which is pretty straight
> forward, essentially a receive loop that grabs the message and
> file:write_file's it to the file system) on another node, which does not
> have a copy of my module?
>
> I thought I would be able to make a fun that returns the mentioned fun
> above
> and then spawn that message sink on another node.
>
> I am investigating writing a file propagation system and it would be nice
> if
> there is one process that gets notified of new files, which spawns a fun on
> each recipient node, which tells that node how to handle it.
>
> Any insights? Or should each node be running a file sink that just listens
> for these {save, Data} msgs? I am trying to write something where I dont
> have to manage the child nodes and their code. Perhaps a file sink
> gen_server on each node that supports upgrades?
>
> Regards,
> Marcel
>


More information about the erlang-questions mailing list