New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ref: Rationalize kafka config - take 2 #66242
Conversation
This reverts commit 369b089.
src/sentry/consumers/__init__.py
Outdated
from arroyo.backends.kafka.configuration import build_kafka_consumer_configuration | ||
from arroyo.backends.kafka.consumer import KafkaConsumer | ||
from arroyo.commit import ONCE_PER_SECOND | ||
from arroyo.types import Topic as ArroyoTopic | ||
from django.conf import settings | ||
|
||
from sentry.utils import kafka_config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a lot of these imports can be removed entirely -- or moved to the top of the file (some are already there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved up the arroyo imports, gonna leave the rest as-is
SNUBA_SPANS = "snuba-spans" | ||
|
||
|
||
class ConsumerDefinition(TypedDict, total=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this actually supposed to be total=False
? all keys are optional?
I usually find for dicts where the are some required keys that it's easier to understand if the not-require ones are marked NotRequired
rather than total=False
+ Required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure, i'm somewhat reluctant to touch this code in this PR. it's just copy + paste
dlq_max_invalid_ratio: float | None | ||
dlq_max_consecutive_count: int | None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these actually nullable or are they meant to be NotRequired
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think nullable is right here
def validate_consumer_definition(consumer_definition: ConsumerDefinition) -> None: | ||
if "dlq_topic" not in consumer_definition and ( | ||
"dlq_max_invalid_ratio" in consumer_definition | ||
or "dlq_max_consecutive_count" in consumer_definition | ||
): | ||
raise ValueError( | ||
"Invalid consumer definition, dlq_max_invalid_ratio/dlq_max_consecutive_count is configured, but dlq_topic is not" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, the intention of the types
modules is that they are just types -- this kind of goes against it by having logic here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just copy + paste
Redo of #65793 with fixed imports