Skip to content

Commit 14807d1

Browse files
committed
docs: refine function doc
1 parent 93aa9cc commit 14807d1

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/kpro_req_lib.erl

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,24 +249,30 @@ fetch(Vsn, Topic, Partition, Offset, Opts) ->
249249
],
250250
make(fetch, Vsn, Fields).
251251

252-
%% @doc Help function to construct a produce request.
252+
%% @doc Help function to construct a non-transactional produce request.
253+
%% `Batch' arg can be be a `[map()]' like `[#{key => Key, value => Value, ts => Ts}]'.
254+
%% Current system time will be taken if `ts' is missing in batch input.
255+
%% It may also be `binary()' or `{magic_v2, Bytes, iolist()}' if user choose to encode
256+
%% a batch beforehand which could be helpful when a large batch can be encoded
257+
%% in other processes.
258+
-spec produce(vsn(), topic(), partition(),
259+
binary() | batch_input() | {magic_v2, non_neg_integer(), iolist()}) -> req().
253260
produce(Vsn, Topic, Partition, Batch) ->
254261
produce(Vsn, Topic, Partition, Batch, #{}).
255262

256263
%% @doc Help function to construct a produce request.
257264
%% By default, it constructs a non-transactional produce request.
265+
%% `Batch' arg can be be a `[map()]' like `[#{key => Key, value => Value, ts => Ts}]'.
266+
%% Current system time will be taken if `ts' is missing in batch input.
267+
%% It may also be `binary()' or `{magic_v2, Bytes, iolist()}' if user choose to encode
268+
%% a batch beforehand which could be helpful when a large batch can be encoded
269+
%% in other processes.
258270
%% For transactional produce requests, below conditions should be met.
259-
%% 1. `Batch' arg must be be a `[map()]' to indicate magic v2,
260-
%% for example: `[#{key => Key, value => Value, ts => Ts}]'.
261-
%% Current system time will be taken if `ts' is missing in batch input.
262-
%% It may also be `binary()' or `{magic_v2, Bytes, iolist()}' if user choose to encode
263-
%% a batch beforehand which could be helpful when a large batch can be encoded
264-
%% in other processes.
265-
%% 2. `first_sequence' must exist in `Opts'.
266-
%% It should be the sequence number for the fist message in batch.
267-
%% Maintained by producer, sequence numbers should start from zero and be
268-
%% monotonically increasing, with one sequence number per topic-partition.
269-
%% 3. `txn_ctx' (which is of spec `kpro:txn_ctx()') must exist in `Opts'
271+
%% - `first_sequence' must exist in `Opts'.
272+
%% It should be the sequence number for the fist message in batch.
273+
%% Maintained by producer, sequence numbers should start from zero and be
274+
%% monotonically increasing, with one sequence number per topic-partition.
275+
%% - `txn_ctx' (which is of spec `kpro:txn_ctx()') must exist in `Opts'
270276
-spec produce(vsn(), topic(), partition(),
271277
binary() | batch_input() | {magic_v2, non_neg_integer(), iolist()}, produce_opts()) -> req().
272278
produce(Vsn, Topic, Partition, Batch, Opts) ->

0 commit comments

Comments
 (0)