Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocking request issue #64

Open
arkanmgerges opened this issue Aug 25, 2017 · 0 comments
Open

Blocking request issue #64

arkanmgerges opened this issue Aug 25, 2017 · 0 comments

Comments

@arkanmgerges
Copy link

Hi,
I'm currently using this app in my production code, I had an issue with blocking requests. I have a timeout returned from init() to be handled in to handle_info(), and from there I'm casting a request with gen_server:cast() to be handled into handle_cast().
Inside I'm calling a function that has this code snippet:
try erlastic_search:search_limit(<<"message">>, <<"inbox">>, <<<<"userId:">>/binary, A/binary, "&_source=''">>, 9999) of
{ok, Resp} ->
{<<"hits">>, Hits} = lists:keyfind(<<"hits">>, 1, Resp),
{<<"hits">>, Hits1} = lists:keyfind(<<"hits">>, 1, Hits),
parse_es_response_data_to_id_list(Hits1);
_ -> []
catch
: -> []
end.

First time this code will work, but then it will not work, I think there is something related to Hackney, I'm not sure.
Currently I solved the issue by adding error() before {noreply, State} inside handle_cast(), and now the code is working on production:

handle_cast({disableMessages, UserId}, State) ->
IdList = fetch_msg_id_list_for(UserId),
set_msg_availability(IdList, <<"false">>),
error(break_blocking), <------------------------ this solved my issue
{noreply, State};

Thanks for your time and effort for providing libraries and applications for the Erlang community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant