Skip to content

Commit

Permalink
fix: return partition count -1 when unavailable.
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhuyan committed Jan 24, 2024
1 parent fe8e71e commit a9b5a0d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/wolff_producers.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down Expand Up @@ -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}),
Expand Down

0 comments on commit a9b5a0d

Please sign in to comment.