jaydoane commented on a change in pull request #1: Fix compiler warnings URL: https://github.com/apache/couchdb-ken/pull/1#discussion_r259450446
########## File path: src/ken_server.erl ########## @@ -509,16 +515,35 @@ resubmit(Delay, DbName) -> end. prune_worker_table(State) -> - {A, B, _} = now(), - C = (1000000 * A) + B - 0.001 * State#state.delay, - MatchHead = #job{worker_pid=nil, lru={'$1','$2','_'}, _='_'}, - Guard = {'<', {'+', {'*', '$1', 1000000}, '$2'}, C}, + % remove all entries older than specified `delay` in milliseconds + Delay = erlang:convert_time_unit(State#state.delay, millisecond, native), + C = erlang:monotonic_time() - Delay, + %% fun(#job{worker_pid=nil, lru=A) when A < C -> true end + MatchHead = #job{worker_pid=nil, lru='$1', _='_'}, + Guard = {'<', '$1', C}, ets:select_delete(ken_workers, [{MatchHead, [Guard], [true]}]), - State#state{pruned_last = now()}. + State#state{pruned_last = erlang:monotonic_time()}. allowed_languages() -> Config = config:get("query_servers") ++ config:get("native_query_servers"), [list_to_binary(Lang) || {Lang, _Cmd} <- Config]. config(Key, Default) -> config:get("ken", Key, Default). + +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). + +prune_old_entried_test() -> Review comment: I think this should be `prune_old_entries_test`? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services