Skip to content

Commit 85f7e55

Browse files
committed
Switch from escript to rebar3 for build management
1 parent 55216bd commit 85f7e55

18 files changed

+162
-49
lines changed

erlang/.gitignore

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,20 @@
1-
.erlang.mk/
2-
deps/
1+
.rebar3
2+
_build
3+
_checkouts
4+
_vendor
5+
.eunit
6+
*.o
7+
*.beam
8+
*.plt
9+
*.swp
10+
*.swo
11+
.erlang.cookie
12+
ebin
13+
log
14+
erl_crash.dump
15+
.rebar
16+
logs
17+
.idea
18+
*.iml
19+
rebar3.crashdump
20+
*~

erlang/Makefile

-5
This file was deleted.

erlang/README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@ You also need rebar3: https://www.rebar3.org/docs/getting-started/
1919

2020
You need Erlang Client binaries:
2121

22-
make all
22+
rebar3 compile
2323

2424
## Code
2525

2626
[Tutorial one: "Hello World!"](https://www.rabbitmq.com/tutorials/tutorial-one-python.html):
2727

28-
./send.erl
29-
./receive.erl
28+
rebar3 shell --eval 'send:start(), init:stop().'
29+
rebar3 shell --eval 'recv:start(), init:stop().'
3030

3131
[Tutorial two: Work Queues](https://www.rabbitmq.com/tutorials/tutorial-two-python.html):
3232

33-
./new_task.erl "A very hard task which takes two seconds.."
34-
./worker.erl
33+
rebar3 shell --eval 'new_task:start(["A very hard task which takes two seconds"]), init:stop().'
34+
rebar3 shell --eval 'worker:start(), init:stop().'
3535

3636
[Tutorial three: Publish/Subscribe](https://www.rabbitmq.com/tutorials/tutorial-three-python.html):
3737

38-
./receive_logs.erl
39-
./emit_log.erl "info: This is the log message"
38+
rebar3 shell --eval 'receive_logs:start(), init:stop().'
39+
rebar3 shell --eval 'emit_log:start(["Info: This is the log message"]), init:stop().'
4040

4141
[Tutorial four: Routing](https://www.rabbitmq.com/tutorials/tutorial-four-python.html):
4242

43-
./receive_logs_direct.erl info
44-
./emit_log_direct.erl info Hello
43+
rebar3 shell --eval 'receive_logs_direct:start(["info"]), init:stop().'
44+
rebar3 shell --eval 'emit_log_direct:start(["info", "Hello"]), init:stop().'
4545

4646
[Tutorial five: Topics](https://www.rabbitmq.com/tutorials/tutorial-five-python.html):
4747

48-
./receive_logs_topic.erl "*.rabbit"
49-
./emit_log_topic.erl red.rabbit Hello
48+
rebar3 shell --eval 'receive_logs_topic:start(["*.rabbit"]), init:stop().'
49+
rebar3 shell --eval 'emit_log_topic:start(["red.rabbit", "Hello"]), init:stop().'

erlang/rebar.config

+10-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
{deps, [{amqp_client, "3.12.2"}]}.
1+
{erl_opts, [debug_info]}.
2+
3+
{deps, [
4+
{amqp_client, "3.12.2"}
5+
]}.
6+
7+
{shell, [
8+
%% {config, "config/sys.config"},
9+
{apps, [erlang]}
10+
]}.

erlang/rebar.lock

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{"1.2.0",
2+
[{<<"amqp_client">>,{pkg,<<"amqp_client">>,<<"3.12.2">>},0},
3+
{<<"credentials_obfuscation">>,
4+
{pkg,<<"credentials_obfuscation">>,<<"3.4.0">>},
5+
1},
6+
{<<"rabbit_common">>,{pkg,<<"rabbit_common">>,<<"3.12.2">>},1},
7+
{<<"recon">>,{pkg,<<"recon">>,<<"2.5.3">>},2},
8+
{<<"thoas">>,{pkg,<<"thoas">>,<<"1.0.0">>},2}]}.
9+
[
10+
{pkg_hash,[
11+
{<<"amqp_client">>, <<"19770F1075FE697BEA8AA77E29DF38BD8A439F8D9F1D8A8FCCB56AE0C7AF73CD">>},
12+
{<<"credentials_obfuscation">>, <<"34E18B126B3AEFD6E8143776FBE1CECEEA6792307C99AC5EE8687911F048CFD7">>},
13+
{<<"rabbit_common">>, <<"FA46F2954F6F5E28D69AFDEFB10F15C4782402411FAC743BC2459A07DCF83B4C">>},
14+
{<<"recon">>, <<"739107B9050EA683C30E96DE050BC59248FD27EC147696F79A8797FF9FA17153">>},
15+
{<<"thoas">>, <<"567C03902920827A18A89F05B79A37B5BF93553154B883E0131801600CF02CE0">>}]},
16+
{pkg_hash_ext,[
17+
{<<"amqp_client">>, <<"004BBF9A4129751195660D5347FD89675564C298979C834189E9B24677AFAE94">>},
18+
{<<"credentials_obfuscation">>, <<"738ACE0ED5545D2710D3F7383906FC6F6B582D019036E5269C4DBD85DBCED566">>},
19+
{<<"rabbit_common">>, <<"33FE4EB510B1E72A2734B9C3D081F76059A07ED7D76C9B9403276AF9D5AFC1B1">>},
20+
{<<"recon">>, <<"6C6683F46FD4A1DFD98404B9F78DCABC7FCD8826613A89DCB984727A8C3099D7">>},
21+
{<<"thoas">>, <<"FC763185B932ECB32A554FB735EE03C3B6B1B31366077A2427D2A97F3BD26735">>}]}
22+
].

erlang/emit_log.erl renamed to erlang/src/emit_log.erl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env escript
2-
%%! -pz ./_build/default/lib/amqp_client/ebin ./_build/default/lib/credentials_obfuscation/ebin ./_build/default/lib/thoas/ebin ./_build/default/lib/rabbit_common/ebin ./_build/default/lib/recon/ebin
1+
-module(emit_log).
2+
-export([start/1]).
33

44
-include_lib("amqp_client/include/amqp_client.hrl").
55

6-
main(Argv) ->
6+
start(Argv) ->
77
{ok, Connection} =
88
amqp_connection:start(#amqp_params_network{host = "localhost"}),
99
{ok, Channel} = amqp_connection:open_channel(Connection),

erlang/emit_log_direct.erl renamed to erlang/src/emit_log_direct.erl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env escript
2-
%%! -pz ./_build/default/lib/amqp_client/ebin ./_build/default/lib/credentials_obfuscation/ebin ./_build/default/lib/thoas/ebin ./_build/default/lib/rabbit_common/ebin ./_build/default/lib/recon/ebin
1+
-module(emit_log_direct).
2+
-export([start/1]).
33

44
-include_lib("amqp_client/include/amqp_client.hrl").
55

6-
main(Argv) ->
6+
start(Argv) ->
77
{ok, Connection} =
88
amqp_connection:start(#amqp_params_network{host = "localhost"}),
99
{ok, Channel} = amqp_connection:open_channel(Connection),

erlang/emit_log_topic.erl renamed to erlang/src/emit_log_topic.erl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env escript
2-
%%! -pz ./_build/default/lib/amqp_client/ebin ./_build/default/lib/credentials_obfuscation/ebin ./_build/default/lib/thoas/ebin ./_build/default/lib/rabbit_common/ebin ./_build/default/lib/recon/ebin
1+
-module(emit_log_topic).
2+
-export([start/1]).
33

44
-include_lib("amqp_client/include/amqp_client.hrl").
55

6-
main(Argv) ->
6+
start(Argv) ->
77
{ok, Connection} =
88
amqp_connection:start(#amqp_params_network{host = "localhost"}),
99
{ok, Channel} = amqp_connection:open_channel(Connection),

erlang/src/erlang.app.src

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{application, erlang, [
2+
{description, "An OTP application"},
3+
{vsn, "0.1.0"},
4+
{registered, []},
5+
{mod, {erlang_app, []}},
6+
{applications, [
7+
kernel,
8+
stdlib
9+
]},
10+
{env, []},
11+
{modules, []},
12+
{licenses, ["Apache-2.0"]},
13+
{links, []}
14+
]}.

erlang/src/erlang_app.erl

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
%%%-------------------------------------------------------------------
2+
%% @doc erlang public API
3+
%% @end
4+
%%%-------------------------------------------------------------------
5+
6+
-module(erlang_app).
7+
8+
-behaviour(application).
9+
10+
-export([start/2, stop/1]).
11+
12+
start(_StartType, _StartArgs) ->
13+
erlang_sup:start_link().
14+
15+
stop(_State) ->
16+
ok.
17+
18+
%% internal functions

erlang/src/erlang_sup.erl

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
%%%-------------------------------------------------------------------
2+
%% @doc erlang top level supervisor.
3+
%% @end
4+
%%%-------------------------------------------------------------------
5+
6+
-module(erlang_sup).
7+
8+
-behaviour(supervisor).
9+
10+
-export([start_link/0]).
11+
12+
-export([init/1]).
13+
14+
-define(SERVER, ?MODULE).
15+
16+
start_link() ->
17+
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
18+
19+
%% sup_flags() = #{strategy => strategy(), % optional
20+
%% intensity => non_neg_integer(), % optional
21+
%% period => pos_integer()} % optional
22+
%% child_spec() = #{id => child_id(), % mandatory
23+
%% start => mfargs(), % mandatory
24+
%% restart => restart(), % optional
25+
%% shutdown => shutdown(), % optional
26+
%% type => worker(), % optional
27+
%% modules => modules()} % optional
28+
init([]) ->
29+
SupFlags = #{
30+
strategy => one_for_all,
31+
intensity => 0,
32+
period => 1
33+
},
34+
ChildSpecs = [],
35+
{ok, {SupFlags, ChildSpecs}}.
36+
37+
%% internal functions

erlang/new_task.erl renamed to erlang/src/new_task.erl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env escript
2-
%%! -pz ./_build/default/lib/amqp_client/ebin ./_build/default/lib/credentials_obfuscation/ebin ./_build/default/lib/thoas/ebin ./_build/default/lib/rabbit_common/ebin ./_build/default/lib/recon/ebin
1+
-module(new_task).
2+
-export([start/1]).
33

44
-include_lib("amqp_client/include/amqp_client.hrl").
55

6-
main(Argv) ->
6+
start(Argv) ->
77
{ok, Connection} =
88
amqp_connection:start(#amqp_params_network{host = "localhost"}),
99
{ok, Channel} = amqp_connection:open_channel(Connection),

erlang/receive_logs.erl renamed to erlang/src/receive_logs.erl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env escript
2-
%%! -pz ./_build/default/lib/amqp_client/ebin ./_build/default/lib/credentials_obfuscation/ebin ./_build/default/lib/thoas/ebin ./_build/default/lib/rabbit_common/ebin ./_build/default/lib/recon/ebin
1+
-module(receive_logs).
2+
-export([start/0]).
33

44
-include_lib("amqp_client/include/amqp_client.hrl").
55

6-
main(_) ->
6+
start() ->
77
{ok, Connection} =
88
amqp_connection:start(#amqp_params_network{host = "localhost"}),
99
{ok, Channel} = amqp_connection:open_channel(Connection),

erlang/receive_logs_direct.erl renamed to erlang/src/receive_logs_direct.erl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env escript
2-
%%! -pz ./_build/default/lib/amqp_client/ebin ./_build/default/lib/credentials_obfuscation/ebin ./_build/default/lib/thoas/ebin ./_build/default/lib/rabbit_common/ebin ./_build/default/lib/recon/ebin
1+
-module(receive_logs_direct).
2+
-export([start/1]).
33

44
-include_lib("amqp_client/include/amqp_client.hrl").
55

6-
main(Argv) ->
6+
start(Argv) ->
77
{ok, Connection} =
88
amqp_connection:start(#amqp_params_network{host = "localhost"}),
99
{ok, Channel} = amqp_connection:open_channel(Connection),

erlang/receive_logs_topic.erl renamed to erlang/src/receive_logs_topic.erl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env escript
2-
%%! -pz ./_build/default/lib/amqp_client/ebin ./_build/default/lib/credentials_obfuscation/ebin ./_build/default/lib/thoas/ebin ./_build/default/lib/rabbit_common/ebin ./_build/default/lib/recon/ebin
1+
-module(receive_logs_topic).
2+
-export([start/1]).
33

44
-include_lib("amqp_client/include/amqp_client.hrl").
55

6-
main(Argv) ->
6+
start(Argv) ->
77
{ok, Connection} =
88
amqp_connection:start(#amqp_params_network{host = "localhost"}),
99
{ok, Channel} = amqp_connection:open_channel(Connection),

erlang/receive.erl renamed to erlang/src/recv.erl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env escript
2-
%%! -pz ./_build/default/lib/amqp_client/ebin ./_build/default/lib/credentials_obfuscation/ebin ./_build/default/lib/thoas/ebin ./_build/default/lib/rabbit_common/ebin ./_build/default/lib/recon/ebin
1+
-module(recv).
2+
-export([start/0]).
33

44
-include_lib("amqp_client/include/amqp_client.hrl").
55

6-
main(_) ->
6+
start() ->
77
{ok, Connection} =
88
amqp_connection:start(#amqp_params_network{host = "localhost", heartbeat = 30}),
99
{ok, Channel} = amqp_connection:open_channel(Connection),

erlang/send.erl renamed to erlang/src/send.erl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env escript
2-
%%! -pz ./_build/default/lib/amqp_client/ebin ./_build/default/lib/credentials_obfuscation/ebin ./_build/default/lib/thoas/ebin ./_build/default/lib/rabbit_common/ebin ./_build/default/lib/recon/ebin
1+
-module(send).
2+
-export([start/0]).
33

44
-include_lib("amqp_client/include/amqp_client.hrl").
55

6-
main(_) ->
6+
start() ->
77
{ok, Connection} =
88
amqp_connection:start(#amqp_params_network{host = "localhost"}),
99
{ok, Channel} = amqp_connection:open_channel(Connection),

erlang/worker.erl renamed to erlang/src/worker.erl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env escript
2-
%%! -pz ./_build/default/lib/amqp_client/ebin ./_build/default/lib/credentials_obfuscation/ebin ./_build/default/lib/thoas/ebin ./_build/default/lib/rabbit_common/ebin ./_build/default/lib/recon/ebin
1+
-module(worker).
2+
-export([start/0]).
33

44
-include_lib("amqp_client/include/amqp_client.hrl").
55

6-
main(_) ->
6+
start() ->
77
{ok, Connection} =
88
amqp_connection:start(#amqp_params_network{host = "localhost"}),
99
{ok, Channel} = amqp_connection:open_channel(Connection),

0 commit comments

Comments
 (0)