Skip to content
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
- 4.5.0
- Expose `create_partitions` from the underlying kafka_protocol
- Allow partitions to automatically have producers started for newly discovered partitions.

- 4.4.0
- Support `zstd` compression.
Expand Down
41 changes: 41 additions & 0 deletions src/brod.erl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
%% Topic APIs
-export([ create_topics/3
, create_topics/4
, create_partitions/3
, create_partitions/4
, delete_topics/3
, delete_topics/4
]).
Expand Down Expand Up @@ -190,6 +192,7 @@
-type endpoint() :: {hostname(), portnum()}.
-type topic() :: kpro:topic().
-type topic_config() :: kpro:struct().
-type topic_partition_config() :: kpro:struct().
-type partition() :: kpro:partition().
-type topic_partition() :: {topic(), partition()}.
-type offset() :: kpro:offset(). %% Physical offset (an integer)
Expand Down Expand Up @@ -1049,6 +1052,44 @@ create_topics(Hosts, TopicConfigs, RequestConfigs) ->
create_topics(Hosts, TopicConfigs, RequestConfigs, Options) ->
brod_utils:create_topics(Hosts, TopicConfigs, RequestConfigs, Options).

%% @equiv create_partitions(Hosts, TopicPartitionConfigs, RequestConfigs, [])
-spec create_partitions([endpoint()], [topic_partition_config()], #{timeout => kpro:int32()}) ->
ok | {error, any()}.
create_partitions(Hosts, TopicPartitionConfigs, RequestConfigs) ->
brod_utils:create_partitions(Hosts, TopicPartitionConfigs, RequestConfigs).

%% @doc Create partitions(s) in kafka.
%% <ul>
%% <li>`topic'
%% The topic name.
%% </li>
%%
%% <li>`new_partitions'
%% The `count` of how many partitions will exist for the topic. current + desired
%% The number of `assignment` should be equal to the number of new partitions.
%% Each list for assignment specify the prefferred broker ids to assign
%% </li>
%%
%% Example:
%% ```
%% > TopicPartitionConfigs = [
%% #{
%% topic: <<"my_topic">>,
%% new_partitions: #{
%% count: 6,
%% assignment: [[1,2], [2,3], [3,1]]
%% }
%% }
%% ].
%% > brod:create_partitions([{"localhost", 9092}], TopicPartitionConfigs, #{timeout => 1000}, []).
%% ok
%% '''
-spec create_partitions([endpoint()], [topic_partition_config()], #{timeout => kpro:int32()},
conn_config()) ->
ok | {error, any()}.
create_partitions(Hosts, TopicPartitionConfigs, RequestConfigs, Options) ->
brod_utils:create_partitions(Hosts, TopicPartitionConfigs, RequestConfigs, Options).

%% @equiv delete_topics(Hosts, Topics, Timeout, [])
-spec delete_topics([endpoint()], [topic()], pos_integer()) ->
ok | {error, any()}.
Expand Down
Loading
Loading