-
-
Notifications
You must be signed in to change notification settings - Fork 230
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
Feature: Response callback fun #314
Comments
I would like to see a better fledged interface proposal. Know which messages it is expected to replace, how it deals with data or trailers and so on. I would favor changing |
If
I think it is almost equivalent to
I don't mind the latter, but I don't think it is necessary. If |
Those funs don't survive module reloads. So we need to have a tuple at least as an option. |
Interesting. I didn't think about funs that become invalid when their module's old code is purged. Is it only a fun with explicit module like Regarding the possibility to update St, we don't need it now but I think we can't add it later if we don't add in from the start. So how about this proposal: To keep the inteface simple, it would receive exactly the same messages as the existing ReplyTo pid does. |
We would like to be able to provide a callback that handles the response, rather than only a
reply_to
pid, in ReqOpts ingun:request/6
.Suggested interface:
#{callback_fun => CallbackFun}
in ReqOpts.ReplyTo ! {gun_response, ...}
, the callback is used asCallbackFun(ReplyTo, {gun_response, ...})
Alternatively, allow ReplyTo to be a fun instead of a pid.
Why not just use
reply_to
pid?Our worker process handles messages from many different sources. It is not supposed to pattern match on gun-specific messages like
{gun_response, ...}
and{gun_error, ...}
because it breaks the abstractions.The callback fun would in this case just translate the message to a different form before sending it to the worker process. Today we have a temporary proxy process for this, which we want to get rid of.
Another benefit of a callback fun is that it can filter messages (ignore some responses or errors) and do simple things like logging directly from the gun worker process, to avoid one hop of message passing.
What do you think? If it is acceptable, I will submit a PR.
The text was updated successfully, but these errors were encountered: