Skip to content

Commit

Permalink
[RTI-8010] Update dependencies and ensure the project works with OTP22 (
Browse files Browse the repository at this point in the history
#22)

* [RTI-8010] Update dependencies and ensure the project works with OTP22

* [RTI-8010] Apply formatting and linting
  • Loading branch information
Brujo Benavides authored Apr 22, 2020
1 parent 97f7cd6 commit 0b2ee43
Show file tree
Hide file tree
Showing 16 changed files with 905 additions and 1,003 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ os:
- linux

otp_release:
- 20.3
- 21.3
- 22.3

notifications:
email: [email protected]
Expand All @@ -15,4 +15,5 @@ script:
- export PATH=/home/travis/.cache/rebar3/bin:$PATH
- rebar3 --version
- erl -version
- rebar3 format --verify
- rebar3 test
34 changes: 34 additions & 0 deletions elvis.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
elvis,
[
{config,
[#{dirs => ["src"],
filter => "*.erl",
ruleset => erl_files,
ignore => ["src/kpl_agg_pb.erl"],
rules => [
{elvis_style, line_length, #{limit => 120, skip_comments => whole_line}},
{elvis_style, nesting_level, #{level => 4}},
{elvis_style, dont_repeat_yourself, #{min_complexity => 20}},
{elvis_style, invalid_dynamic_call, disable},
{elvis_style, no_debug_call, #{ignore => [erlmld_noisy_wrk, erlmld_runner]}}
]
},
#{dirs => ["."],
filter => "*rebar.config",
ruleset => rebar_config,
rules => [
%% Elixir deps use git@...
{elvis_project, protocol_for_deps_rebar, disable}
]
},
#{dirs => ["."],
filter => "elvis.config",
ruleset => elvis_config
}
]
}
]
}
].
53 changes: 22 additions & 31 deletions include/erlmld.hrl
Original file line number Diff line number Diff line change
@@ -1,43 +1,35 @@
-ifndef(ERLMLD_HRL).
-define(ERLMLD_HRL, true).

-record(sequence_number, {
%% overall record sequence number:
base :: undefined | non_neg_integer() | atom(),

%% record sub-sequence number for records using KPL aggregation:
sub :: undefined | non_neg_integer(),

%% record sub-sequence number for records NOT using KPL aggregation.
%% erlmld supports its own KPL-like aggregation and will fill this
%% one when needed. For other use cases, your code is expected to
%% fake these when needed.
user_sub :: undefined | non_neg_integer(),

%% total number of records in aggregated KPL record:
%% (user_sub will range from 0 to user_total-1)
user_total :: undefined | non_neg_integer()
}).

-record(checkpoint, {
sequence_number :: undefined | sequence_number()
}).
-define(ERLMLD_HRL, true).

-record(stream_record, {
partition_key :: binary(),
timestamp :: undefined | non_neg_integer(), % approximate arrival time (ms)
delay :: non_neg_integer(), % approximate delay between this record and tip of stream (ms)
sequence_number :: sequence_number(),
data :: term()
}).
-record(sequence_number,
{%% overall record sequence number:
base :: undefined | non_neg_integer() | atom(),
%% record sub-sequence number for records using KPL aggregation:
sub :: undefined | non_neg_integer(),
%% record sub-sequence number for records NOT using KPL aggregation.
%% erlmld supports its own KPL-like aggregation and will fill this
%% one when needed. For other use cases, your code is expected to
%% fake these when needed.
user_sub :: undefined | non_neg_integer(),
%% total number of records in aggregated KPL record:
%% (user_sub will range from 0 to user_total-1)
user_total :: undefined | non_neg_integer()}).
-record(checkpoint, {sequence_number :: undefined | sequence_number()}).
-record(stream_record,
{partition_key :: binary(),
timestamp :: undefined | non_neg_integer(), % approximate arrival time (ms)
delay ::
non_neg_integer(), % approximate delay between this record and tip of stream (ms)
sequence_number :: sequence_number(),
data :: term()}).

-type worker_state() :: term().
-type shard_id() :: binary().
-type sequence_number() :: #sequence_number{}.
-type stream_record() :: #stream_record{}.
-type shutdown_reason() :: terminate | zombie.
-type checkpoint() :: #checkpoint{}.

%% Types used by the flusher behavior (see erlmld_flusher.erl).
-type flusher_state() :: term().
-type flusher_token() :: term().
Expand All @@ -50,7 +42,6 @@
%% with version 1.1.1 of the dynamo streams adapter doesn't properly deaggregate (doesn't
%% include subsequence numbers in the records we see).
-define(KPL_AGG_MAGIC, <<16#00, 16#89, 16#9A, 16#C2>>).

%% magic number identifying deflate-compressed KPL record, compressed using
%% zlib:compress/1. the KPL checksum trailer is included in the deflated data.
-define(KPL_AGG_MAGIC_DEFLATED, <<16#01, 16#89, 16#9A, 16#C2>>).
Expand Down
14 changes: 8 additions & 6 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
% -*- mode: erlang -*-
{erl_opts, [debug_info]}.

{deps, [
{jiffy, "1.0.1"},
{erlexec, "1.10.0"}
]}.
{deps, [{jiffy, "1.0.4"}, {erlexec, "1.10.9"}]}.


{plugins, [
{ rebar3_gpb_plugin, "2.8.2" }
{rebar3_gpb_plugin, "2.13.1"},
rebar3_lint,
rebar3_format,
rebar3_hex
]}.

{erl_opts, [{i, "./_build/default/plugins/gpb/include"}]}.
Expand Down Expand Up @@ -50,4 +50,6 @@

{cover_enabled, true}.

{alias, [{test, [xref, dialyzer, eunit, cover]}]}.
{alias, [{test, [format, lint, xref, dialyzer, eunit, cover]}]}.

{format, [{files, ["src/*.erl", "include/*.hrl"]}]}.
8 changes: 4 additions & 4 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{"1.1.0",
[{<<"erlexec">>,{pkg,<<"erlexec">>,<<"1.10.0">>},0},
{<<"jiffy">>,{pkg,<<"jiffy">>,<<"1.0.1">>},0}]}.
[{<<"erlexec">>,{pkg,<<"erlexec">>,<<"1.10.9">>},0},
{<<"jiffy">>,{pkg,<<"jiffy">>,<<"1.0.4">>},0}]}.
[
{pkg_hash,[
{<<"erlexec">>, <<"CBA7924CF526097D2082CEB0EC34E7DB6BCA2624B8F3867FB3FA89C4CF25D227">>},
{<<"jiffy">>, <<"4F25639772CA41202F41BA9C8F6CA0933554283DD4742C90651E03471C55E341">>}]}
{<<"erlexec">>, <<"3CBB3476F942BFB8B68B85721C21C1835061CF6DD35F5285C2362E85B100DDC7">>},
{<<"jiffy">>, <<"72ADEFF75C52A2FF07DE738F0813768ABE7CE158026CC1115A170340259C0CAA">>}]}
].
17 changes: 7 additions & 10 deletions src/erlmld_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@

-behaviour(application).

-export([start/2, stop/1,
ensure_all_started/0]).

-export([start/2, stop/1, ensure_all_started/0]).

%% application callback. load default configuration from application environment, and
%% start erlmd_sup with that configuration.
start(_StartType, []) ->
Opts = maps:from_list(application:get_all_env(erlmld)),
erlmld_sup:start_link(Opts).


stop(_State) ->
ok.


ensure_all_started() ->
{ok, Deps} = application:get_key(erlmld, applications),
{ok, lists:append([begin
{ok, Started} = application:ensure_all_started(Dep),
Started
end
|| Dep <- Deps])}.
{ok,
lists:append([begin
{ok, Started} = application:ensure_all_started(Dep),
Started
end
|| Dep <- Deps])}.
Loading

0 comments on commit 0b2ee43

Please sign in to comment.