@@ -71,7 +71,6 @@ class Settings(BaseSettings):
7171 ALLOWED_HOSTS : list [str ] = ["localhost" , "127.0.0.1" , "api.localhost" ]
7272 CORS_ORIGINS : list [str ] = ["localhost" , "127.0.0.1" ]
7373
74- APP_LOG_FILE_PATH : str = "logs/app.log"
7574 API_BASE_PATH : str = "/api"
7675 APP_VERSION : str = "latest"
7776 APP_HOST : str = "0.0.0.0"
@@ -177,7 +176,9 @@ def bearer_token_url(self) -> str:
177176 # E.G. http://localhost:4317
178177 OPENTELEMETRY_ENDPOINT : str | None = None
179178
180- KAFKA_ADDR : list [str ] = ["app-kafka:9092" ]
179+ # Kafka
180+ KAFKA_CLIENT_ID : str = "api"
181+ KAFKA_PORT : int = 9092
181182
182183 # Additional Project Settings
183184 BASE_API_PATH : str = "/api"
@@ -215,7 +216,7 @@ def redis_url(self) -> URL:
215216 path = f"/{ self .REDIS_DATABASE } "
216217 return URL .build (
217218 scheme = "redis" ,
218- host = self .REDIS_HOST ,
219+ host = "localhost" if self . ENVIRONMENT in [ "debug" , "local" ] else self .REDIS_HOST ,
219220 port = self .REDIS_PORT ,
220221 password = self .REDIS_PASS ,
221222 path = path ,
@@ -230,12 +231,18 @@ def rabbit_url(self) -> URL:
230231 """
231232 return URL .build (
232233 scheme = "amqp" ,
233- host = self .RABBITMQ_HOST ,
234+ host = "localhost" if self . ENVIRONMENT in [ "debug" , "local" ] else self .RABBITMQ_HOST ,
234235 port = self .RABBITMQ_PORT ,
235236 user = self .RABBITMQ_USER ,
236237 password = self .RABBITMQ_PASS ,
237238 path = self .RABBITMQ_VHOST ,
238239 )
239240
241+ @property
242+ def kafka_url (self ) -> str :
243+ """Assemble Kafka broker URL from settings."""
244+ host = "localhost" if self .ENVIRONMENT in ["debug" , "local" ] else self .KAFKA_CONTAINER_HOST
245+ return f"{ host } :{ self .KAFKA_PORT } "
246+
240247
241248settings = Settings ()
0 commit comments