feat(broker): reflect persisted messages in publish result
In order for callers to distinguish between silently dropped and durably persisted message w/o matching subscribers.
This commit is contained in:
parent
f4953e719b
commit
e713fc38aa
|
@ -224,8 +224,17 @@ publish(Msg) when is_record(Msg, message) ->
|
|||
}),
|
||||
[];
|
||||
Msg1 = #message{topic = Topic} ->
|
||||
_ = emqx_persistent_message:persist(Msg1),
|
||||
route(aggre(emqx_router:match_routes(Topic)), delivery(Msg1))
|
||||
PersistRes = persist_publish(Msg1),
|
||||
PersistRes ++ route(aggre(emqx_router:match_routes(Topic)), delivery(Msg1))
|
||||
end.
|
||||
|
||||
persist_publish(Msg) ->
|
||||
case emqx_persistent_message:persist(Msg) of
|
||||
ok ->
|
||||
[persisted];
|
||||
{_SkipOrError, _Reason} ->
|
||||
% TODO: log errors?
|
||||
[]
|
||||
end.
|
||||
|
||||
%% Called internally
|
||||
|
|
|
@ -244,6 +244,7 @@
|
|||
-type publish_result() :: [
|
||||
{node(), topic(), deliver_result()}
|
||||
| {share, topic(), deliver_result()}
|
||||
| persisted
|
||||
].
|
||||
-type route() :: #route{}.
|
||||
-type route_entry() :: {topic(), node()} | {topic, group()}.
|
||||
|
|
Loading…
Reference in New Issue