Permalink
Browse files

Set offset.

  • Loading branch information...
1 parent 8042ef9 commit 08cd33587a66e873e3f3973c0d8400ff5512b097 @knutin knutin committed Feb 2, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 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) ->

0 comments on commit 08cd335

Please sign in to comment.