Skip to content

Commit

Permalink
Introduce erlang distribution
Browse files Browse the repository at this point in the history
- Add support for handshake from OTP nodes
- Add support for monitoring processes and sending messages to registered
processes from OTP nodes

Signed-off-by: Paul Guyot <pguyot@kallisys.net>
  • Loading branch information
pguyot committed Jan 6, 2025
1 parent 2159b25 commit 9f2317b
Show file tree
Hide file tree
Showing 22 changed files with 2,126 additions and 17 deletions.
1 change: 1 addition & 0 deletions examples/erlang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ pack_runnable(mqtt_client mqtt_client estdlib eavmlib)
pack_runnable(network_console network_console estdlib eavmlib alisp)
pack_runnable(logging_example logging_example estdlib eavmlib)
pack_runnable(http_client http_client estdlib eavmlib)
pack_runnable(disterl disterl estdlib)
41 changes: 41 additions & 0 deletions examples/erlang/disterl.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
%
% This file is part of AtomVM.
%
% Copyright 2024 Paul Guyot <pguyot@kallisys.net>
%
% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
% You may obtain a copy of the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS,
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and
% limitations under the License.
%
% SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
%

-module(disterl).

-export([start/0]).

start() ->
{ok, _KernelPid} = kernel:start(normal, []),
{ok, _NetKernelPid} = net_kernel:start('atomvm@127.0.0.1', #{name_domain => longnames}),
io:format("Distribution was started\n"),
io:format("Node is ~p\n", [node()]),
net_kernel:set_cookie(<<"AtomVM">>),
io:format("Cookie is ~s\n", [net_kernel:get_cookie()]),
register(disterl, self()),
io:format(
"This AtomVM node is waiting for 'quit' message, and this process is registered as 'disterl'\n"
),
io:format("On an OTP node with long names distribution, run:\n"),
io:format("erlang:set_cookie('atomvm@127.0.0.1', 'AtomVM').\n"),
io:format("{disterl, 'atomvm@127.0.0.1'} ! quit.\n"),
receive
quit -> ok
end.
6 changes: 6 additions & 0 deletions libs/estdlib/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set(ERLANG_MODULES
calendar
code
crypto
dist_util
erl_epmd
erts_debug
ets
Expand All @@ -41,6 +42,9 @@ set(ERLANG_MODULES
gen_tcp_inet
gen_tcp_socket
supervisor
kernel
net_kernel
net_kernel_sup
inet
io_lib
io
Expand All @@ -54,6 +58,8 @@ set(ERLANG_MODULES
queue
sets
socket
socket_dist
socket_dist_controller
ssl
string
timer
Expand Down
Loading

0 comments on commit 9f2317b

Please sign in to comment.