Skip to content

Commit b92eba2

Browse files
authored
update erlang runtime and dependencies (#7685)
1 parent 5f9d3e0 commit b92eba2

12 files changed

+54
-59
lines changed

frameworks/Erlang/chicagoboss/chicagoboss.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM erlang:18.3.4.8
1+
FROM erlang:25.1-alpine
22

33
ADD ./ /chicagoboss
44
WORKDIR /chicagoboss

frameworks/Erlang/chicagoboss/rebar.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{deps, [
2-
{boss, ".*", {git, "git://github.com/ChicagoBoss/ChicagoBoss.git", {tag, "v0.9.pre-alpha-2"}}}
2+
{boss, ".*", {git, "git://github.com/ChicagoBoss/ChicagoBoss.git", {tag, "0.9.0"}}}
33
]}.
44
{plugin_dir, ["priv/rebar"]}.
55
{plugins, [boss_plugin]}.

frameworks/Erlang/cowboy/cowboy.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM erlang:21.1.1
1+
FROM erlang:25.1
22

33
ADD ./ /cowboy
44
WORKDIR /cowboy

frameworks/Erlang/cowboy/rebar.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{deps,
22
[
3-
{jiffy, ".*", {git, "https://github.com/davisp/jiffy.git", {tag, "0.15.2"}}},
3+
{jiffy, ".*", {git, "https://github.com/davisp/jiffy.git", {tag, "1.1.1"}}},
44
{mimetypes, ".*", {git, "http://github.com/spawngrid/mimetypes.git", {branch, master}}},
55
{emysql, ".*", {git, "https://github.com/deadtrickster/Emysql.git", "52b802098322aad372198b9f5fa9ae9a4c758ad1"}},
6-
{cowboy, ".*", {git, "https://github.com/ninenines/cowboy.git", {tag, "2.5.0"}}}
6+
{cowboy, ".*", {git, "https://github.com/ninenines/cowboy.git", {tag, "2.9.0"}}}
77
]}.

frameworks/Erlang/cowboy/src/hello_world_app.erl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@
1717

1818

1919
start(_Type, _Args) ->
20-
crypto:start(),
21-
application:start(emysql),
22-
emysql:add_pool(test_pool, 256,
23-
"benchmarkdbuser", "benchmarkdbpass", "tfb-database", 3306,
24-
"hello_world", utf8),
25-
emysql:prepare(db_stmt, <<"SELECT * FROM World where id = ?">>),
26-
Dispatch = cowboy_router:compile([
27-
{'_', [
28-
{"/plaintext", plaintext_handler, []},
29-
{"/json", json_handler, []},
30-
{"/db", db_handler, []},
31-
{"/query", query_handler, []}
32-
]}
33-
]),
34-
{ok, _} = cowboy:start_clear(http, [{port, 8080}], #{env => #{dispatch => Dispatch}}
35-
),
36-
hello_world_sup:start_link().
20+
crypto:start(),
21+
application:start(emysql),
22+
emysql:add_pool(test_pool, 256,
23+
"benchmarkdbuser", "benchmarkdbpass", "tfb-database", 3306,
24+
"hello_world", utf8),
25+
emysql:prepare(db_stmt, <<"SELECT * FROM World where id = ?">>),
26+
Dispatch = cowboy_router:compile([
27+
{'_', [
28+
{"/plaintext", plaintext_handler, []},
29+
{"/json", json_handler, []},
30+
{"/db", db_handler, []},
31+
{"/query", query_handler, []}
32+
]}
33+
]),
34+
{ok, _} = cowboy:start_clear(http, [{port, 8080}], #{env => #{dispatch => Dispatch}}
35+
),
36+
hello_world_sup:start_link().
3737

3838
stop(_State) ->
39-
ok.
39+
ok.

frameworks/Erlang/elli/elli.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM erlang:18.3.4.8
1+
FROM erlang:25.1
22

33
WORKDIR /elli
44
COPY src src

frameworks/Erlang/elli/rebar.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{deps,
22
[
3-
{jiffy, ".*", {git, "https://github.com/davisp/jiffy.git", {tag, "0.15.0"}}},
3+
{jiffy, ".*", {git, "https://github.com/davisp/jiffy.git", {tag, "1.1.1"}}},
44
{emysql, ".*", {git, "https://github.com/deadtrickster/Emysql.git", "52b802098322aad372198b9f5fa9ae9a4c758ad1"}},
5-
{elli, "", {git, "https://github.com/knutin/elli.git", {tag, "v1.0.5"}}}
5+
{elli, ".*", {git, "https://github.com/elli-lib/elli.git", {tag, "3.3.0"}}}
66
]}.

frameworks/Erlang/mochiweb/mochiweb.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM erlang:18.3.4.8
1+
FROM erlang:23
22

33
ADD ./ /mochiweb
44
WORKDIR /mochiweb

frameworks/Erlang/mochiweb/rebar.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
%% -*- erlang -*-
22
{deps, [
3-
{mochiweb, "2.9.0", {git, "https://github.com/mochi/mochiweb.git", {tag, "v2.9.0"}}},
4-
{jsonx, ".*", {git, "https://github.com/iskra/jsonx.git", "9c95948c6835827ed61a9506ae4a9aba61acf335"}},
3+
{mochiweb, ".*", {git, "https://github.com/mochi/mochiweb.git", {tag, "v2.20.1"}}},
4+
{jiffy, ".*", {git, "https://github.com/davisp/jiffy.git", {tag, "1.1.1"}}},
55
{emysql, ".*", {git, "https://github.com/deadtrickster/Emysql.git"}},
6-
{erlydtl, "0.11.1", {git, "https://github.com/erlydtl/erlydtl.git", {tag, "0.11.1"}}}
6+
{erlydtl, ".*", {git, "https://github.com/erlydtl/erlydtl.git", {tag, "0.14.0"}}}
77
]}.
88
{erlydtl_opts, [
99
{doc_root, "priv/templates"},

frameworks/Erlang/mochiweb/src/erl_bench.erl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,20 @@
22
-export([hello_json/0, hello_plain/0, random_json/0, randoms_json/1, update_randoms_json/1, fortunes_html/0]).
33

44
hello_json() ->
5-
jsonx:encode([{<<"message">>, <<"Hello, World!">>}]).
5+
{[{<<"message">>, <<"Hello, World!">>}]}.
66

77
hello_plain() ->
88
<<"Hello, world!">>.
99

1010
random_json() ->
1111
RandomId = randoms:random_id(),
12-
jsonx:encode(find(RandomId)).
12+
find(RandomId).
1313

1414
randoms_json(Count) ->
15-
Json = [find(Id) || Id <- randoms:random_ids(Count)],
16-
jsonx:encode(Json).
15+
[find(Id) || Id <- randoms:random_ids(Count)].
1716

1817
update_randoms_json(Count) ->
19-
Json = [update(Id) || Id <- randoms:random_ids(Count)],
20-
jsonx:encode(Json).
18+
[update(Id) || Id <- randoms:random_ids(Count)].
2119

2220
fortunes_html() ->
2321
Props = [[{message, Message}, {id, Id}] || {Message, Id} <- fortunes:all()],
@@ -28,8 +26,8 @@ fortunes_html() ->
2826

2927
find(Id) ->
3028
{Id, RandomNumber} = randoms:find(Id),
31-
[{<<"id">>, Id}, {<<"randomNumber">>, RandomNumber}].
29+
{[{<<"id">>, Id}, {<<"randomNumber">>, RandomNumber}]}.
3230

3331
update(Id) ->
3432
{Id, RandomNumber} = randoms:update(Id),
35-
[{<<"id">>, Id}, {<<"randomNumber">>, RandomNumber}].
33+
{[{<<"id">>, Id}, {<<"randomNumber">>, RandomNumber}]}.

frameworks/Erlang/mochiweb/src/randoms.erl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
-define(world_max_records, 10000).
55

66
init() ->
7-
random:seed(erlang:now()),
87
emysql:prepare(find_random, <<"SELECT id, randomNumber FROM World WHERE id = ? LIMIT 1;">>),
98
emysql:prepare(update_random, <<"UPDATE World SET randomNumber = ? WHERE id = ? LIMIT 1;">>).
109

11-
random_id() -> random:uniform(?world_max_records).
10+
random_id() -> rand:uniform(?world_max_records).
1211

1312
random_ids(Times) -> random_ids(Times, []).
1413

@@ -20,7 +19,7 @@ find(Id) ->
2019
{Id, RandomNumber}.
2120

2221
update(Id) ->
23-
NewRandomNumber = random:uniform(10000),
22+
NewRandomNumber = rand:uniform(10000),
2423
emysql:execute(db_pool, update_random, [NewRandomNumber, Id]),
2524
{Id, NewRandomNumber}.
2625

frameworks/Erlang/mochiweb/src/web_handler.erl

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,49 @@ stop() ->
99
mochiweb_http:stop(?MODULE).
1010

1111
dispatch(Req) ->
12-
Method = Req:get(method),
13-
Path = string:tokens(Req:get(path), "/"),
12+
Method = mochiweb_request:get(method, Req),
13+
Path = mochiweb_request:get(path, Req),
1414
handle(Method, Path, Req).
1515

1616
%% handle
1717

18-
handle('GET', ["json"], Req) ->
18+
handle('GET', "/json", Req) ->
1919
json(Req, erl_bench:hello_json());
2020

21-
handle('GET', ["plaintext"], Req) ->
21+
handle('GET', "/plaintext", Req) ->
2222
plain(Req, erl_bench:hello_plain());
2323

24-
handle('GET', ["db"], Req) ->
25-
json(Req, erl_bench:random_json());
24+
handle('GET', "/db", Req) ->
25+
Json = erl_bench:random_json(),
26+
json(Req, Json);
2627

27-
handle('GET', ["queries"], Req) ->
28+
handle('GET', "/queries", Req) ->
2829
Queries = queries(Req),
2930
json(Req, erl_bench:randoms_json(Queries));
3031

31-
handle('GET', ["updates"], Req) ->
32+
handle('GET', "/updates", Req) ->
3233
Queries = queries(Req),
3334
json(Req, erl_bench:update_randoms_json(Queries));
3435

35-
handle('GET', ["fortunes"], Req) ->
36-
fortune(Req, erl_bench:fortunes_html());
36+
handle('GET', "/fortunes", Req) ->
37+
html(Req, erl_bench:fortunes_html());
3738

3839
handle(_Method, _Path, Req) ->
39-
Req:respond({404, [{"Content-Type", "text/plain"}], "Not Found"}).
40+
mochiweb_request:respond({404, [{"Content-Type", "text/plain"}], "404 Not Found"}, Req).
4041

4142
%% private
4243

4344
json(Req, Json) ->
44-
Req:ok({"application/json", Json}).
45+
mochiweb_request:ok({"application/json", jiffy:encode(Json)}, Req).
4546

4647
plain(Req, Text) ->
47-
Req:ok({"text/plain", Text}).
48+
mochiweb_request:ok({"text/plain", Text}, Req).
4849

4950
html(Req, Html) ->
50-
Req:ok({"text/html", Html}).
51-
52-
fortune(Req, Html) ->
53-
Req:ok({"text/html;charset=UTF-8", Html}).
51+
mochiweb_request:ok({"text/html;charset=UTF-8", Html}, Req).
5452

5553
queries(Req) ->
56-
Params = Req:parse_qs(),
54+
Params = mochiweb_request:parse_qs(Req),
5755
Queries = (catch list_to_integer(proplists:get_value("queries", Params, "1"))),
5856
case {is_number(Queries), Queries > 500} of
5957
{true, true} -> 500;

0 commit comments

Comments
 (0)