From d18ea8300759e7d539ed493dffa0d638f81e0125 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Tue, 18 Jun 2024 11:55:02 +0100 Subject: [PATCH 1/7] Bump rebar3_lint from ~> 1.0.2 to ~> 3.2.5 Approaches OTP 27 -based development --- rebar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index d6a68551..51e4d6b7 100644 --- a/rebar.config +++ b/rebar.config @@ -1,7 +1,7 @@ {deps, [ {kafka_protocol, "4.1.5"} , {snappyer, "1.2.9"} ]}. -{project_plugins, [{coveralls, "~> 2.2.0"}, {rebar3_lint, "~> 1.0.2"}]}. +{project_plugins, [{coveralls, "~> 2.2.0"}, {rebar3_lint, "~> 3.2.5"}]}. {edoc_opts, [{preprocess, true}, {macros, [{build_brod_cli, true}]}]}. {erl_opts, [warnings_as_errors, warn_unused_vars,warn_shadow_vars,warn_obsolete_guard,debug_info]}. {xref_checks, [undefined_function_calls, undefined_functions, From 1d97f36eaf11a0b2624d991688a83b86aba5663a Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Tue, 18 Jun 2024 12:30:01 +0100 Subject: [PATCH 2/7] Update as per rebar3 do unlock --all, upgrade --all I noticed rebar.lock was outdated against rebar.config --- rebar.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rebar.lock b/rebar.lock index 0a925d0e..71217547 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,14 +1,14 @@ {"1.2.0", [{<<"crc32cer">>,{pkg,<<"crc32cer">>,<<"0.1.8">>},1}, - {<<"kafka_protocol">>,{pkg,<<"kafka_protocol">>,<<"4.1.3">>},0}, + {<<"kafka_protocol">>,{pkg,<<"kafka_protocol">>,<<"4.1.5">>},0}, {<<"snappyer">>,{pkg,<<"snappyer">>,<<"1.2.9">>},0}]}. [ {pkg_hash,[ {<<"crc32cer">>, <<"C6C2275C5FB60A95F4935D414F30B50EE9CFED494081C9B36EBB02EDFC2F48DB">>}, - {<<"kafka_protocol">>, <<"362D85A898D4148A43DBABB10A30BB2D6FF32BA0097EB06981D11B34E2E0A9CD">>}, + {<<"kafka_protocol">>, <<"D15E64994A8CA99716AB47DB4132614359AC1BFA56D6C5B4341FDC1AA4041518">>}, {<<"snappyer">>, <<"9CC58470798648CE34C662CA0AA6DAAE31367667714C9A543384430A3586E5D3">>}]}, {pkg_hash_ext,[ {<<"crc32cer">>, <<"251499085482920DEB6C9B7AADABF9FB4C432F96ADD97AB42AEE4501E5B6F591">>}, - {<<"kafka_protocol">>, <<"28CF73001270D972524DD0FAD4A59074F4441219F9CF237AD808A2AC1EC97487">>}, + {<<"kafka_protocol">>, <<"C956C9357FEF493B7072A35D0C3E2BE02AA5186C804A412D29E62423BB15E5D9">>}, {<<"snappyer">>, <<"18D00CA218AE613416E6EECAFE1078DB86342A66F86277BD45C95F05BF1C8B29">>}]} ]. From cf3bd74a9166c3504ff20c332f5f0ba14a3a2903 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Tue, 18 Jun 2024 12:45:15 +0100 Subject: [PATCH 3/7] Move to gen_server:format_status/1 as per OTP constraints format_status/1 was introduced in OTP 25 format_status/2 is now having brod compilation fail, because of warnings_as_errors (in OTP 27) This commit presents one possibility to solve the issue: adopt the new format_status, which means that effectively brod becomes >= OTP 25 Another possibility is to remove warnings_as_errors and keep current behaviour until the function is removed from OTP I opted to remove format_status/2 from brod_supervisor/3 as it's doing mostly nothing relevant except "flagging" state.module as "Callback" --- src/brod_producer.erl | 10 +++++----- src/brod_supervisor3.erl | 8 +------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/brod_producer.erl b/src/brod_producer.erl index 9f9466f5..991237d5 100644 --- a/src/brod_producer.erl +++ b/src/brod_producer.erl @@ -36,7 +36,7 @@ , handle_info/2 , init/1 , terminate/2 - , format_status/2 + , format_status/1 ]). -export([ do_send_fun/4 @@ -408,12 +408,12 @@ terminate(Reason, #state{client_pid = ClientPid ok. %% @private -format_status(normal, [_PDict, State=#state{}]) -> - [{data, [{"State", State}]}]; -format_status(terminate, [_PDict, State=#state{buffer = Buffer}]) -> +format_status(#{reason := normal} = Status) -> + Status; +format_status(#{reason := terminate, state := #state{buffer = Buffer} = State} = Status) -> %% Do not format the buffer attribute when process terminates abnormally and logs an error %% but allow it when is a sys:get_status/1.2 - State#state{buffer = brod_producer_buffer:empty_buffers(Buffer)}. + Status#{state => State#state{buffer = brod_producer_buffer:empty_buffers(Buffer)}}. %%%_* Internal Functions ======================================================= diff --git a/src/brod_supervisor3.erl b/src/brod_supervisor3.erl index dd2e4b3e..ba5187c6 100644 --- a/src/brod_supervisor3.erl +++ b/src/brod_supervisor3.erl @@ -82,7 +82,7 @@ %% Internal exports -export([init/1, handle_call/3, handle_cast/2, handle_info/2, - terminate/2, code_change/3, format_status/2]). + terminate/2, code_change/3]). -export([try_again_restart/3]). %%-------------------------------------------------------------------------- @@ -735,12 +735,6 @@ code_change(_, State, _) -> Error end. -format_status(terminate, [_PDict, State]) -> - State; -format_status(_, [_PDict, State]) -> - [{data, [{"State", State}]}, - {supervisor, [{"Callback", State#state.module}]}]. - check_flags({Strategy, MaxIntensity, Period}) -> valid_strategy(Strategy), valid_intensity(MaxIntensity), From 32c0c2c5b71d17babe3e8ae4afc310cc7f8ce0a5 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Tue, 18 Jun 2024 12:54:31 +0100 Subject: [PATCH 4/7] Bump test dep. snabbkaffe from 1.0.8 to 1.0.10 --- rebar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index 51e4d6b7..c9ca8c2c 100644 --- a/rebar.config +++ b/rebar.config @@ -28,7 +28,7 @@ , {jsone, "1.7.0"} , {meck, "0.9.2"} , {proper, "1.4.0"} - , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {branch, "1.0.8"}}} + , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {branch, "1.0.10"}}} ]}, {erl_opts, [warnings_as_errors, {d, build_brod_cli}]} ]} From b38712dc94da4e4bf66be3d54c7990ab21a3f2e7 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Mon, 24 Jun 2024 10:37:28 +0100 Subject: [PATCH 5/7] Act on review comments: keep pre-25 compatibility --- src/brod_producer.erl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/brod_producer.erl b/src/brod_producer.erl index 991237d5..1cd55583 100644 --- a/src/brod_producer.erl +++ b/src/brod_producer.erl @@ -36,9 +36,14 @@ , handle_info/2 , init/1 , terminate/2 - , format_status/1 ]). +-if(?OTP_RELEASE < 25). +-export([format_status/2]). +-else. +-export([format_status/1]). +-endif. + -export([ do_send_fun/4 , do_no_ack/2 , do_bufcb/2 @@ -408,12 +413,21 @@ terminate(Reason, #state{client_pid = ClientPid ok. %% @private +-if(?OTP_RELEASE < 25). +format_status(normal, [_PDict, State=#state{}]) -> + [{data, [{"State", State}]}]; +format_status(terminate, [_PDict, State=#state{buffer = Buffer}]) -> + %% Do not format the buffer attribute when process terminates abnormally and logs an error + %% but allow it when is a sys:get_status/1.2 + State#state{buffer = brod_producer_buffer:empty_buffers(Buffer)}. +-else. format_status(#{reason := normal} = Status) -> Status; format_status(#{reason := terminate, state := #state{buffer = Buffer} = State} = Status) -> %% Do not format the buffer attribute when process terminates abnormally and logs an error %% but allow it when is a sys:get_status/1.2 Status#{state => State#state{buffer = brod_producer_buffer:empty_buffers(Buffer)}}. +-endif. %%%_* Internal Functions ======================================================= From 45c7b7211ff5cb3c4f9d637aae0b6e4dd008d915 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Mon, 24 Jun 2024 10:37:46 +0100 Subject: [PATCH 6/7] Act on review comments: also test on OTP 27 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 209da873..719f5d8b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,7 +44,7 @@ jobs: strategy: fail-fast: false matrix: - otp: ["26"] + otp: ["26", "27"] kafka: ["0.9", "0.10", "0.11", "2.8", "1.1", "3.6"] steps: - name: Checkout From 42a954b15764e091d805fb0a64583178dbdfaba4 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Mon, 24 Jun 2024 12:23:08 +0100 Subject: [PATCH 7/7] Test with rebar3 3.23.0 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 719f5d8b..70d17a88 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ on: - master env: OTP_VERSION: "26" - REBAR_VERSION: "3.20.0" + REBAR_VERSION: "3.23.0" jobs: lint: