-
Notifications
You must be signed in to change notification settings - Fork 69
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
client stream callbacks #127
base: master
Are you sure you want to change the base?
Conversation
f9f15ba
to
9dad094
Compare
I ended up including the fix for OTP-21 warnings in this, so ignore that from my original comment. |
true -> | ||
erlang:apply(Mod, Fun, AllArgs); | ||
false -> | ||
{ok, State} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why this isn't an error? in what case would a callback function specified not exist but not be an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user doesn't have to support every callback from h2_stream. Maybe they should, or at least some f them, but I just went with not requiring any stream handling callback being required from the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@talentdeficit ping
@tsloughter
and other function must handle the returned result. |
@getong chatterbox was already using |
@tsloughter Could you please make a separate PR with the |
Sure. |
When remote HTTP server is down, in h2_connection:init/1 Transport:connect will return econnrefused. As this call is handled in h2_connection:init/1, current code returns {stop,econnrefused}. Although this is handled gracefully by clients, we do see an CRASH report saying that: `[error] CRASH REPORT Process <0.2985.0> with 0 neighbours exited with reason: econnrefused in gen_statem:init_result/6 line 728` gen_statem:init origin routine would have called exit with a reason code other than normal and this triggers the CRASH report. If the gen_statem client has returned ignore, the gen_statem process would have exited with exit(normal) and will not trigger this CRASH
When remote HTTP server is down, in h2_connection:init/1 Transport:connect will return econnrefused. As this call is handled in h2_connection:init/1, current code returns {stop,econnrefused}. Although this is handled gracefully by clients, we do see an CRASH report saying that: `[error] CRASH REPORT Process <0.2985.0> with 0 neighbours exited with reason: econnrefused in gen_statem:init_result/6 line 728` gen_statem:init origin routine would have called exit with a reason code other than normal and this triggers the CRASH report. If the gen_statem module has returned {stop, {shutdown,Reason}}, the gen_statem process would call Module:terminate/1 and exit appropriately without a crash report.
This patch makes it so a callback module can be defined for clients to handle streaming responses. I am using this for building client support in https://github.com/tsloughter/grpcbox
I think there still needs to be updates to how it keeps the response body the way it does in the close stream record when the callback is
undefined
, but I'm not sure yet what would be a better solution, if there is one.I also removed the no longer used static content handler.
I'll fix up the removal of warnings as errors in another PR, which will probably get in before this one, so it can be added back soon in this PR.