Skip to content

Commit

Permalink
Remove the mam*_flush_messages hooks
Browse files Browse the repository at this point in the history
These hooks were used only for instrumentation,
and they are redundant, because mongoose_instrument has flush events
with the same data.
Also, the MUC hook was not instrumented for some reason.
  • Loading branch information
chrzaszcz committed Jun 3, 2024
1 parent 0acb72c commit 4c4d89d
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 21 deletions.
18 changes: 0 additions & 18 deletions src/hooks/mongoose_hooks.erl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
mam_remove_archive/3,
mam_lookup_messages/2,
mam_archive_message/2,
mam_flush_messages/2,
mam_archive_sync/1,
mam_retraction/3]).

Expand All @@ -106,7 +105,6 @@
mam_muc_remove_archive/3,
mam_muc_lookup_messages/2,
mam_muc_archive_message/2,
mam_muc_flush_messages/2,
mam_muc_archive_sync/1,
mam_muc_retraction/3]).

Expand Down Expand Up @@ -1005,14 +1003,6 @@ mam_lookup_messages(HostType, Params) ->
mam_archive_message(HostType, Params) ->
run_hook_for_host_type(mam_archive_message, HostType, ok, Params).

%%% @doc The `mam_flush_messages' hook is run after the async bulk write
%%% happens for messages despite the result of the write.
-spec mam_flush_messages(HostType :: mongooseim:host_type(),
MessageCount :: integer()) -> ok.
mam_flush_messages(HostType, MessageCount) ->
Params = #{count => MessageCount},
run_hook_for_host_type(mam_flush_messages, HostType, ok, Params).

%% @doc Waits until all pending messages are written
-spec mam_archive_sync(HostType :: mongooseim:host_type()) -> ok.
mam_archive_sync(HostType) ->
Expand Down Expand Up @@ -1133,14 +1123,6 @@ mam_muc_lookup_messages(HostType, Params) ->
mam_muc_archive_message(HostType, Params) ->
run_hook_for_host_type(mam_muc_archive_message, HostType, ok, Params).

%%% @doc The `mam_muc_flush_messages' hook is run after the async bulk write
%%% happens for MUC messages despite the result of the write.
-spec mam_muc_flush_messages(HostType :: mongooseim:host_type(),
MessageCount :: integer()) -> ok.
mam_muc_flush_messages(HostType, MessageCount) ->
Params = #{count => MessageCount},
run_hook_for_host_type(mam_muc_flush_messages, HostType, ok, Params).

%% @doc Waits until all pending messages are written
-spec mam_muc_archive_sync(HostType :: mongooseim:host_type()) -> ok.
mam_muc_archive_sync(HostType) ->
Expand Down
1 change: 0 additions & 1 deletion src/instrument/mongoose_instrument_hooks.erl
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,4 @@ is_instrumented(mam_muc_set_prefs) -> false;
is_instrumented(mam_muc_remove_archive) -> false;
is_instrumented(mam_muc_lookup_messages) -> false;
is_instrumented(mam_muc_archive_message) -> false;
is_instrumented(mam_muc_flush_messages) -> false;
is_instrumented(_) -> true.
1 change: 0 additions & 1 deletion src/mam/mod_mam_muc_rdbms_arch_async.erl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ do_flush_muc(Acc, #{host_type := HostType, queue_length := MessageCount,
process_list_results(Process, HostType)
end,
[mod_mam_muc_rdbms_arch:retract_message(HostType, Params) || Params <- Acc],
mongoose_hooks:mam_muc_flush_messages(HostType, MessageCount),
ok.

process_batch_result({updated, _Count}, _, _, _) ->
Expand Down
1 change: 0 additions & 1 deletion src/mam/mod_mam_rdbms_arch_async.erl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ do_flush_pm(Acc, #{host_type := HostType, queue_length := MessageCount,
process_list_results(Process, HostType)
end,
[mod_mam_rdbms_arch:retract_message(HostType, Params) || Params <- Acc],
mongoose_hooks:mam_flush_messages(HostType, MessageCount),
ok.

process_batch_result({updated, _Count}, _, _, _) ->
Expand Down

0 comments on commit 4c4d89d

Please sign in to comment.