Skip to content
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

Merged
merged 3 commits into from Mar 4, 2024
Merged

Conversation

lynnagara
Copy link
Member

Redo of #65793 with fixed imports

@lynnagara lynnagara requested a review from a team as a code owner March 4, 2024 19:56
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 4, 2024
Comment on lines 383 to 389
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
Copy link
Member

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)

Copy link
Member Author

@lynnagara lynnagara Mar 4, 2024

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):
Copy link
Member

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

Copy link
Member Author

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

Comment on lines +74 to +75
dlq_max_invalid_ratio: float | None
dlq_max_consecutive_count: int | None
Copy link
Member

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

Copy link
Member Author

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

Comment on lines +78 to +85
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"
)
Copy link
Member

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

Copy link
Member Author

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

@lynnagara lynnagara enabled auto-merge (squash) March 4, 2024 20:17
@lynnagara lynnagara merged commit 2ad12d6 into master Mar 4, 2024
50 checks passed
@lynnagara lynnagara deleted the rationalize-kafka-config branch March 4, 2024 20:38
@github-actions github-actions bot locked and limited conversation to collaborators Mar 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants