Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Set offset.

  • Loading branch information...
commit 08cd33587a66e873e3f3973c0d8400ff5512b097 1 parent 8042ef9
Knut Nesheim knutin authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/kafka_consumer.erl
10 src/kafka_consumer.erl
View
@@ -5,7 +5,7 @@
-behaviour(gen_server).
%% API
--export([start_link/5, get_current_offset/1, get_offsets/3, fetch/1]).
+-export([start_link/5, get_current_offset/1, get_offsets/3, fetch/1, set_offset/2]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
@@ -33,6 +33,9 @@ get_current_offset(C) ->
get_offsets(C, Time, MaxNumber) ->
gen_server:call(C, {get_offsets, Time, MaxNumber}).
+set_offset(C, Offset) ->
+ gen_server:call(C, {set_offset, Offset}).
+
fetch(C) ->
gen_server:call(C, fetch).
@@ -79,7 +82,10 @@ handle_call({get_offsets, Time, MaxNumber}, _From, State) ->
end;
handle_call(get_current_offset, _From, State) ->
- {reply, {ok, State#state.current_offset}, State}.
+ {reply, {ok, State#state.current_offset}, State};
+handle_call({set_offset, Offset}, _From, State) ->
+ {reply, ok, State#state{current_offset = Offset}}.
+
handle_cast(_Msg, State) ->
Please sign in to comment.
Something went wrong with that request. Please try again.