Skip to content

Commit

Permalink
don't try to send messages of the wrong type
Browse files Browse the repository at this point in the history
SearchIndexer.handle_messages_sync should filter out indexes that don't
support the given message type
  • Loading branch information
aaxelb committed Mar 5, 2021
1 parent 60e4182 commit 73eced0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions share/search/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from contextlib import ExitStack

from django.apps import apps
Expand All @@ -11,6 +12,9 @@
__all__ = ('SearchIndexer', 'MessageType')


logger = logging.getLogger(__name__)


class SearchIndexer:

retry_policy = {
Expand Down Expand Up @@ -72,6 +76,10 @@ def handle_messages_sync(self, message_type, target_ids, index_names=None):

for index_name in index_names:
index_setup = self.elastic_manager.get_index_setup(index_name)
if message_type not in index_setup.supported_message_types:
logger.error(f'skipping: {index_name} does not support {message_type}')
continue

action_generator = index_setup.build_action_generator(index_name, message_type)
elastic_actions = [
elastic_action
Expand Down

0 comments on commit 73eced0

Please sign in to comment.