From 4c4d89ddbeb3a14aea3afbfa00bfcc32677008ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Mon, 3 Jun 2024 08:21:28 +0200 Subject: [PATCH] Remove the mam*_flush_messages hooks 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. --- src/hooks/mongoose_hooks.erl | 18 ------------------ src/instrument/mongoose_instrument_hooks.erl | 1 - src/mam/mod_mam_muc_rdbms_arch_async.erl | 1 - src/mam/mod_mam_rdbms_arch_async.erl | 1 - 4 files changed, 21 deletions(-) diff --git a/src/hooks/mongoose_hooks.erl b/src/hooks/mongoose_hooks.erl index 89808c23ad..bdb0fd5111 100644 --- a/src/hooks/mongoose_hooks.erl +++ b/src/hooks/mongoose_hooks.erl @@ -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]). @@ -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]). @@ -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) -> @@ -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) -> diff --git a/src/instrument/mongoose_instrument_hooks.erl b/src/instrument/mongoose_instrument_hooks.erl index 848a8e3bb1..dbf7a310da 100644 --- a/src/instrument/mongoose_instrument_hooks.erl +++ b/src/instrument/mongoose_instrument_hooks.erl @@ -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. diff --git a/src/mam/mod_mam_muc_rdbms_arch_async.erl b/src/mam/mod_mam_muc_rdbms_arch_async.erl index c5f17c18d9..8d6346bff7 100644 --- a/src/mam/mod_mam_muc_rdbms_arch_async.erl +++ b/src/mam/mod_mam_muc_rdbms_arch_async.erl @@ -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}, _, _, _) -> diff --git a/src/mam/mod_mam_rdbms_arch_async.erl b/src/mam/mod_mam_rdbms_arch_async.erl index ef971127b2..ca465a1c6d 100644 --- a/src/mam/mod_mam_rdbms_arch_async.erl +++ b/src/mam/mod_mam_rdbms_arch_async.erl @@ -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}, _, _, _) ->