-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feat(mqtt-bridge): avoid middleman process #9870
feat(mqtt-bridge): avoid middleman process #9870
Conversation
So that buffer worker would notice a connection loss in time, and recycle inflight messages subsequently.
8e4a13d
to
1bb0945
Compare
Instead, supervise `emqtt` client process directly.
1bb0945
to
30cb2f2
Compare
30cb2f2
to
c5a7cd5
Compare
{ok, WorkerPid}. | ||
case emqx_connector_mqtt_worker:send_to_remote_async(InstanceId, Msg, Callback) of | ||
ok -> | ||
% TODO this is racy |
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.
emqx_connector_mqtt_worker:send_to_remote_async/3
can return {ok, Pid}
?
Fun() | ||
catch | ||
error:badarg -> | ||
maps:get(badarg, Else); |
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.
it seems all badarg
s are mapped to disconnected
, maybe simply return disconnected
when badarg
happens.
catch | ||
error:badarg -> | ||
maps:get(badarg, Else); | ||
exit:{noproc, _} -> |
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.
is noproc
just a race condition of badarg
?
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.
if yes, it should return disconnected
too ?
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 exactly, AFAICS. This is what gen:call
will throw when there's no pid behind a name, even when the gproc
act as a registry.
if yes, it should return
disconnected
too ?
On a second glance the code seems a bit too complicated, so probably yes. I'll open a followup PR.
minor comment fix can be fixed in follow-up PRs. |
Instead, supervise
emqtt
client process directly. New scheme should be much simpler than before.This currently has some minor drawbacks.
EMQX-8798