Skip to content

Commit

Permalink
remove b64fast and make base64 decoder user-configurable (#15)
Browse files Browse the repository at this point in the history
* remove b64fast and make base64 decoder user-configurable

it should be an application-specific decision which base64 decoder to
use; erlang's included module may suffice for many processing
applications.
  • Loading branch information
zerth authored Sep 21, 2018
1 parent eb9a53d commit f566fb1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 24 deletions.
17 changes: 1 addition & 16 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

{deps, [
{jiffy, "0.14.11"},
{erlexec, "1.7.1"},
{b64fast, "0.2.1"}
{erlexec, "1.7.1"}
]}.


Expand All @@ -30,20 +29,6 @@
]}
]}.

{overrides,
[{override, b64fast,
[
{plugins, [pc]},
{artifacts, ["priv/b64fast.so"]},
{so_name, "b64fast.so"},
{provider_hooks, [
{post,
[{compile, {pc, compile}},
{clean, {pc, clean}}]}
]}
]}
]}.

{dialyzer, [
{warnings, [unknown, no_return, error_handling]},
{plt_apps, top_level_deps},
Expand Down
4 changes: 1 addition & 3 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{"1.1.0",
[{<<"b64fast">>,{pkg,<<"b64fast">>,<<"0.2.1">>},0},
{<<"erlexec">>,{pkg,<<"erlexec">>,<<"1.7.1">>},0},
[{<<"erlexec">>,{pkg,<<"erlexec">>,<<"1.7.1">>},0},
{<<"jiffy">>,{pkg,<<"jiffy">>,<<"0.14.11">>},0}]}.
[
{pkg_hash,[
{<<"b64fast">>, <<"EF67EFD73109BF52A83338A2DED30D0DC4EC1B11449B4C43DB970D3FC96CC9CD">>},
{<<"erlexec">>, <<"6DDBD40FA202084ED0BDAF95A50C334ACAA5644AE213B903CD4094A78AE79734">>},
{<<"jiffy">>, <<"919A87D491C5A6B5E3BBC27FAFEDC3A0761CA0B4C405394F121F582FD4E3F0E5">>}]}
].
8 changes: 5 additions & 3 deletions src/erlmld.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
stdlib,
crypto,
erlexec,
jiffy,
b64fast]},
jiffy]},
{modules, []},
{env, [
%% if nonzero, use a specific listen port instead of a random one:
Expand Down Expand Up @@ -89,6 +88,9 @@
%% if true, don't fail if kcl encounters child shards with open parents, which
%% can occur when processing dynamo streams on very large tables (requires
%% patched KCL):
{ignore_unexpected_child_shards, false}
{ignore_unexpected_child_shards, false},

%% base64 decoder {mod, fun}
{base64_decoder, {base64, decode}}
]}
]}.
8 changes: 6 additions & 2 deletions src/erlmld_wrk_statem.erl
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,9 @@ stream_record(Record, PartitionKey, Data, SequenceNumber) ->


deaggregate_kpl_records(R, Records) ->
Base64Decoder = application:get_env(erlmld, base64_decoder, {base64, decode}),
lists:flatmap(fun (#{<<"data">> := RecordData} = Record) ->
%% note: b64fast will fail if the data contains whitespace.
deaggregate_kpl_record(R, Record, b64fast:decode64(RecordData))
deaggregate_kpl_record(R, Record, b64decode(Base64Decoder, RecordData))
end, Records).


Expand Down Expand Up @@ -730,6 +730,10 @@ encode_seqno_base(X) when is_atom(X), X /= undefined ->
atom_to_binary(X, utf8).


b64decode({M, F}, Data) ->
M:F(Data).


%%%===================================================================
%%% TESTS
%%%===================================================================
Expand Down

0 comments on commit f566fb1

Please sign in to comment.