From 125c16780f9dafc0e21130bcf888fce199db94fe Mon Sep 17 00:00:00 2001 From: William Yang Date: Wed, 24 Jan 2024 17:29:42 +0100 Subject: [PATCH] fix: support otp < 26 --- src/wolff_producers.erl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/wolff_producers.erl b/src/wolff_producers.erl index b446163..345c482 100644 --- a/src/wolff_producers.erl +++ b/src/wolff_producers.erl @@ -453,9 +453,20 @@ start_new_producers(#{client_id := ClientId, end, St. + +-if(OTP_RELEASE >= "26"). get_partition_cnt(ClientId, Topic) -> ets:lookup_element(?WOLFF_PRODUCERS_GLOBAL_TABLE, {ClientId, Topic, partition_count}, 2, ?partition_count_unavailable). +-else. +get_partition_cnt(ClientId, Topic) -> + try ets:lookup_element(?WOLFF_PRODUCERS_GLOBAL_TABLE, {ClientId, Topic, partition_count}, + 2) + catch + error:badarg -> + ?partition_count_unavailable + end. +-endif. put_partition_cnt(ClientId, Topic, Count) -> _ = ets:insert(?WOLFF_PRODUCERS_GLOBAL_TABLE, {{ClientId, Topic, partition_count}, Count}),