diff --git a/src/wolff_producers.erl b/src/wolff_producers.erl index ed3c7f5..b446163 100644 --- a/src/wolff_producers.erl +++ b/src/wolff_producers.erl @@ -60,6 +60,7 @@ -define(initialized, initialized). -define(partition_count_refresh_interval_seconds, 300). -define(refresh_partition_count, refresh_partition_count). +-define(partition_count_unavailable, -1). %% @doc Called by wolff_producers_sup to start wolff_producers process. start_link(ClientId, Topic, Config) -> @@ -453,8 +454,8 @@ start_new_producers(#{client_id := ClientId, St. get_partition_cnt(ClientId, Topic) -> - [{_, Count}] = ets:lookup(?WOLFF_PRODUCERS_GLOBAL_TABLE, {ClientId, Topic, partition_count}), - Count. + ets:lookup_element(?WOLFF_PRODUCERS_GLOBAL_TABLE, {ClientId, Topic, partition_count}, + 2, ?partition_count_unavailable). put_partition_cnt(ClientId, Topic, Count) -> _ = ets:insert(?WOLFF_PRODUCERS_GLOBAL_TABLE, {{ClientId, Topic, partition_count}, Count}),