Skip to content
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

fix(exhook): ensuring that exhook dispatches the client events are sequential #8530

Merged
merged 2 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Fix AuthN JWKS SSL schema. Using schema in `emqx_schema`. [#8458](https://github.com/emqx/emqx/pull/8458)
* `sentinel` field should be required when AuthN/AuthZ Redis using sentinel mode. [#8458](https://github.com/emqx/emqx/pull/8458)
* Fix bad swagger format. [#8517](https://github.com/emqx/emqx/pull/8517)
* Ensuring that exhook dispatches the client events are sequential. [#8530](https://github.com/emqx/emqx/pull/8530)

## Enhancements

Expand Down
3 changes: 1 addition & 2 deletions apps/emqx_exhook/rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
]}.

{deps, [
{emqx, {path, "../emqx"}},
{grpc, {git, "https://github.com/emqx/grpc-erl", {tag, "0.6.4"}}}
{emqx, {path, "../emqx"}}
]}.

{grpc, [
Expand Down
2 changes: 1 addition & 1 deletion apps/emqx_exhook/src/emqx_exhook.app.src
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
{application, emqx_exhook, [
{description, "EMQX Extension for Hook"},
{vsn, "5.0.1"},
{vsn, "5.0.2"},
{modules, []},
{registered, []},
{mod, {emqx_exhook_app, []}},
Expand Down
15 changes: 14 additions & 1 deletion apps/emqx_exhook/src/emqx_exhook_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,11 @@ match_topic_filter(TopicName, TopicFilter) ->

-spec do_call(binary(), atom(), atom(), map(), map()) -> {ok, map()} | {error, term()}.
do_call(ChannName, Hookpoint, Fun, Req, ReqOpts) ->
Options = ReqOpts#{channel => ChannName},
NReq = Req#{meta => emqx_exhook_handler:request_meta()},
Options = ReqOpts#{
channel => ChannName,
key_dispatch => key_dispatch(NReq)
},
?SLOG(debug, #{
msg => "do_call",
module => ?PB_CLIENT_MOD,
Expand Down Expand Up @@ -481,3 +484,13 @@ available_hooks() ->
'session.terminated'
| message_hooks()
].

%% @doc Get dispatch_key for each request
key_dispatch(_Req = #{clientinfo := #{clientid := ClientId}}) ->
ClientId;
key_dispatch(_Req = #{conninfo := #{clientid := ClientId}}) ->
ClientId;
key_dispatch(_Req = #{message := #{from := From}}) ->
From;
key_dispatch(_Req) ->
self().
3 changes: 1 addition & 2 deletions apps/emqx_gateway/rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

{erl_opts, [debug_info]}.
{deps, [
{emqx, {path, "../emqx"}},
{grpc, {git, "https://github.com/emqx/grpc-erl", {tag, "0.6.4"}}}
{emqx, {path, "../emqx"}}
]}.

{plugins, [
Expand Down
1 change: 1 addition & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ defmodule EMQXUmbrella.MixProject do
{:esockd, github: "emqx/esockd", tag: "5.9.3", override: true},
{:ekka, github: "emqx/ekka", tag: "0.13.2", override: true},
{:gen_rpc, github: "emqx/gen_rpc", tag: "2.8.1", override: true},
{:grpc, github: "emqx/grpc-erl", tag: "0.6.6", override: true},
{:minirest, github: "emqx/minirest", tag: "1.3.5", override: true},
{:ecpool, github: "emqx/ecpool", tag: "0.5.2"},
{:replayq, "0.3.4", override: true},
Expand Down
1 change: 1 addition & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
, {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.9.3"}}}
, {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.13.2"}}}
, {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.8.1"}}}
, {grpc, {git, "https://github.com/emqx/grpc-erl", {tag, "0.6.6"}}}
, {minirest, {git, "https://github.com/emqx/minirest", {tag, "1.3.5"}}}
, {ecpool, {git, "https://github.com/emqx/ecpool", {tag, "0.5.2"}}}
, {replayq, "0.3.4"}
Expand Down