Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/brod_consumer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
, prefetch_bytes :: non_neg_integer()
, connection_mref :: ?undef | reference()
, isolation_level :: isolation_level()
, rack_id :: ?undef | binary()
}).

-type state() :: #state{}.
Expand Down Expand Up @@ -301,6 +302,7 @@ init({Bootstrap, Topic, Partition, Config}) ->
BeginOffset = Cfg(begin_offset, ?DEFAULT_BEGIN_OFFSET),
OffsetResetPolicy = Cfg(offset_reset_policy, ?DEFAULT_OFFSET_RESET_POLICY),
IsolationLevel = Cfg(isolation_level, ?DEFAULT_ISOLATION_LEVEL),
RackId = Cfg(rack_id, ?undef),

%% If bootstrap is a client pid, register self to the client
case is_shared_conn(Bootstrap) of
Expand Down Expand Up @@ -328,6 +330,7 @@ init({Bootstrap, Topic, Partition, Config}) ->
, size_stat_window = Cfg(size_stat_window, ?DEFAULT_AVG_WINDOW)
, connection_mref = ?undef
, isolation_level = IsolationLevel
, rack_id = RackId
}}.

%% @private
Expand Down Expand Up @@ -730,7 +733,8 @@ send_fetch_request(#state{ begin_offset = BeginOffset
State#state.max_wait_time,
State#state.min_bytes,
State#state.max_bytes,
State#state.isolation_level),
State#state.isolation_level,
State#state.rack_id),
case kpro:request_async(Connection, Request) of
ok ->
State#state{last_req_ref = Request#kpro_req.ref};
Expand Down
15 changes: 15 additions & 0 deletions src/brod_kafka_request.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
-export([ create_topics/3
, delete_topics/3
, fetch/8
, fetch/9
, list_groups/1
, list_offsets/4
, join_group/2
Expand Down Expand Up @@ -89,6 +90,20 @@ fetch(Pid, Topic, Partition, Offset,
, isolation_level => IsolationLevel
}).

-spec fetch(conn(), topic(), partition(), offset(),
kpro:wait(), kpro:count(), kpro:count(),
kpro:isolation_level(), ?undef | binary()) -> kpro:req().
fetch(Pid, Topic, Partition, Offset,
WaitTime, MinBytes, MaxBytes, IsolationLevel, RackId) ->
Vsn = pick_version(fetch, Pid),
kpro_req_lib:fetch(Vsn, Topic, Partition, Offset,
#{ max_wait_time => WaitTime
, min_bytes => MinBytes
, max_bytes => MaxBytes
, isolation_level => IsolationLevel
, rack_id => RackId
}).
Comment on lines +99 to +105
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
kpro_req_lib:fetch(Vsn, Topic, Partition, Offset,
#{ max_wait_time => WaitTime
, min_bytes => MinBytes
, max_bytes => MaxBytes
, isolation_level => IsolationLevel
, rack_id => RackId
}).
kpro_req_lib:fetch(Vsn, Topic, Partition, Offset,
#{ max_wait_time => WaitTime
, min_bytes => MinBytes
, max_bytes => MaxBytes
, isolation_level => IsolationLevel
, rack_id => RackId
}).


%% @doc Make a `list_offsets' request message for offset resolution.
%% In kafka protocol, -2 and -1 are semantic 'time' to request for
%% 'earliest' and 'latest' offsets.
Expand Down