Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/launchpad/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def create_kafka_consumer(
# Get configuration from environment
config = get_kafka_config()

environment = os.getenv("LAUNCHPAD_ENV")
if not environment:
raise ValueError("LAUNCHPAD_ENV environment variable is required")

# Create Arroyo consumer
# TODO: When we're closer to production, we'll need a way to disable this logic as
# topics, partitions and kafka clusters are configured through getsentry/ops.
Expand All @@ -47,12 +51,19 @@ def create_kafka_consumer(
"arroyo.strict.offset.reset": config["arroyo_strict_offset_reset"],
"enable.auto.commit": False,
"enable.auto.offset.store": False,
"security.protocol": config["security.protocol"],
"sasl.mechanism": config["sasl.mechanism"],
"sasl.username": config["sasl.username"],
"sasl.password": config["sasl.password"],
}

# Only include security fields in non-development environments
if environment != "development":
consumer_config.update(
{
"security.protocol": config["security.protocol"],
"sasl.mechanism": config["sasl.mechanism"],
"sasl.username": config["sasl.username"],
"sasl.password": config["sasl.password"],
}
)

arroyo_consumer = ArroyoKafkaConsumer(consumer_config)

# Create strategy factory
Expand Down
Loading