Do hackney_pools work with async requests?
Closed this issue · 3 comments
I looked at this example - https://github.com/benoitc/hackney/blob/master/examples/test_multiple_async.erl - but it appears that the connection pool option is unused here on line 26 - 34:
request(WaitPid) ->
wait_request(),
Url = <<"https://httparrot.herokuapp.com/get">>,
Opts = [async],
{ok, Ref} = hackney:get(Url, [], <<>>, Opts),
loop(Ref, WaitPid).
In this case, the process is added to hackney_manager
.
I've tried the same code, and explicitly added {pool, default}
to the request options, but the request process is still added to the hackney_manager
supervisor, and not the process associated with the 'default' connection pool.
Is this a bug?
not the process associated with the 'default' connection pool.
What do you mean by this ^^ ? How do you observe this?
The manager is part of the things I would like to revisit soon to make the connection supervision lighter. Right now the way the stream process is added is done via the command hackney_manager:start_async_response/1
: https://github.com/benoitc/hackney/blob/master/src/hackney_manager.erl#L153
The command link the request to the stream process and pass the control of the socket to this process. The owner (the process receiving the results) is still linked to the manager in between. Once the response is done, the control of the process is given back to the pool or to the process if requested.
What do you mean by this ^^ ? How do you observe this?
I just make a long running request and use the application tab in Observer to see what children each process is spawning.
I can definitely see the pool process, which wasn't spawning anything.
But hackney_manager did, which was why I wanted to ask.
Sorry for the delay to answer.The pool doesn't spawn anything. instead a process will take socket from it in its current version. The pool process will be rewritten in coming version sometimes this month anyway so closing the issue for now. Feel free to reopen it or open a new one if you have another question.