Skip to content

Commit 6294b8d

Browse files
Omit kafka SASL security flags for local dev (#249)
1 parent 38c0169 commit 6294b8d

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/launchpad/kafka.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ def create_kafka_consumer(
3636
# Get configuration from environment
3737
config = get_kafka_config()
3838

39+
environment = os.getenv("LAUNCHPAD_ENV")
40+
if not environment:
41+
raise ValueError("LAUNCHPAD_ENV environment variable is required")
42+
3943
# Create Arroyo consumer
4044
# TODO: When we're closer to production, we'll need a way to disable this logic as
4145
# topics, partitions and kafka clusters are configured through getsentry/ops.
@@ -47,12 +51,19 @@ def create_kafka_consumer(
4751
"arroyo.strict.offset.reset": config["arroyo_strict_offset_reset"],
4852
"enable.auto.commit": False,
4953
"enable.auto.offset.store": False,
50-
"security.protocol": config["security.protocol"],
51-
"sasl.mechanism": config["sasl.mechanism"],
52-
"sasl.username": config["sasl.username"],
53-
"sasl.password": config["sasl.password"],
5454
}
5555

56+
# Only include security fields in non-development environments
57+
if environment != "development":
58+
consumer_config.update(
59+
{
60+
"security.protocol": config["security.protocol"],
61+
"sasl.mechanism": config["sasl.mechanism"],
62+
"sasl.username": config["sasl.username"],
63+
"sasl.password": config["sasl.password"],
64+
}
65+
)
66+
5667
arroyo_consumer = ArroyoKafkaConsumer(consumer_config)
5768

5869
# Create strategy factory

0 commit comments

Comments
 (0)