/ucengine/src/backends/search/solr/uce_solr_commiter.erl
Erlang | 60 lines | 31 code | 12 blank | 17 comment | 0 complexity | 967b6f2192b2925ef6d810314cf3bf0c MD5 | raw file
- %%
- %% U.C.Engine - Unified Collaboration Engine
- %% Copyright (C) 2011 af83
- %%
- %% This program is free software: you can redistribute it and/or modify
- %% it under the terms of the GNU Affero General Public License as published by
- %% the Free Software Foundation, either version 3 of the License, or
- %% (at your option) any later version.
- %%
- %% This program is distributed in the hope that it will be useful,
- %% but WITHOUT ANY WARRANTY; without even the implied warranty of
- %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- %% GNU Affero General Public License for more details.
- %%
- %% You should have received a copy of the GNU Affero General Public License
- %% along with this program. If not, see <http://www.gnu.org/licenses/>.
- %%
- -module(uce_solr_commiter).
- -behaviour(gen_server).
- -include("uce.hrl").
- -export([start_link/0]).
- -export([init/1,
- code_change/3,
- handle_call/3,
- handle_cast/2,
- handle_info/2,
- terminate/2]).
- start_link() ->
- gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
- init([]) ->
- gen_server:cast(?MODULE, run),
- {ok, nothing}.
- handle_call(_ , _, State) ->
- {reply, ok, State}.
- handle_cast(run, State) ->
- [CommitInterval] = utils:get(config:get(solr), [commit_interval], [1000]),
- timer:sleep(CommitInterval),
- {ok, commited} = uce_event_solr_search:commit(),
- handle_cast(run, State),
- {noreply, State};
- handle_cast(_, State) ->
- {noreply, State}.
- code_change(_,State,_) ->
- {ok, State}.
- handle_info(_Info, State) ->
- {reply, State}.
- terminate(_Reason, _State) ->
- ok.