Skip to content

Commit

Permalink
dont hard code formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
MeredithAnya committed Nov 5, 2024
1 parent 1d34006 commit 6ee920c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions snuba/cli/lw_deletions_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from snuba.datasets.storages.factory import get_writable_storage
from snuba.datasets.storages.storage_key import StorageKey
from snuba.environment import setup_logging, setup_sentry
from snuba.lw_deletions.formatters import SearchIssuesFormatter
from snuba.lw_deletions.formatters import STORAGE_FORMATTER
from snuba.lw_deletions.strategy import ConsumerStrategyFactory
from snuba.utils.metrics.wrapper import MetricsWrapper
from snuba.utils.streams.metrics_adapter import StreamMetricsAdapter
Expand Down Expand Up @@ -143,11 +143,12 @@ def handler(signum: int, frame: Any) -> None:
)

storage = get_writable_storage(StorageKey(storage_name))
formatter = STORAGE_FORMATTER[storage_name]()
strategy_factory = ConsumerStrategyFactory(
max_batch_size=max_batch_size,
max_batch_time_ms=max_batch_time_ms,
storage=storage,
formatter=SearchIssuesFormatter(),
formatter=formatter,
)

consumer = consumer_builder.build_lw_deletions_consumer(strategy_factory)
Expand Down
8 changes: 7 additions & 1 deletion snuba/lw_deletions/formatters.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from abc import ABC, abstractmethod
from typing import MutableMapping, Sequence
from typing import Mapping, MutableMapping, Sequence, Type

from attr import dataclass

from snuba.datasets.storages.storage_key import StorageKey
from snuba.web.bulk_delete_query import ConditionsType, DeleteQueryMessage


Expand Down Expand Up @@ -51,3 +52,8 @@ def format(
}
)
return and_conditions


STORAGE_FORMATTER: Mapping[str, Type[Formatter]] = {
StorageKey.SEARCH_ISSUES.value: SearchIssuesFormatter
}

0 comments on commit 6ee920c

Please sign in to comment.