hackney icon indicating copy to clipboard operation
hackney copied to clipboard

change owner process for async request to stream_to value

Open rutaka-n opened this issue 5 years ago • 2 comments

Hello. I figure out, that hackney starts tracking process which calls hackney:request even if stream_to parameter is passed. I expected that when stream_to passed hackney would track this process. Maybe it should be one more parameter to set the owner process or just use stream_to for this. What do you think? If you agree, I can provide a pull request with changes for this.

Have nice day.

rutaka-n avatar Aug 10 '20 15:08 rutaka-n

I expected that when stream_to passed hackney would track this process.

what would be the main goal of it? Right now the stream "Owner" (which is the Pid set via stream_t is monitored in the stream process: https://github.com/benoitc/hackney/blob/master/src/hackney_stream.erl#L28

Isn't it enough?

benoitc avatar Aug 11 '20 12:08 benoitc

I have a case when a process should send a request to API when it terminates, I wanted to do it in an async manner, so I use async and stream_to options to handle result in another process. But the process which called request terminating, hackney cancel the request before stream_to process gets a response. I am sure that it is a bit strange and rare situation. I think it would be cool to cover it somehow - add the ability to fully change owner process or at least add a notice in the documentation, that in case the owner process is terminated hackney cancels the request.

rutaka-n avatar Aug 11 '20 13:08 rutaka-n