Remove deprecated files and configurations, including .env, Dockerfile, docker-compose.yml, and client-schedule.py. Update README.md to reflect new architecture and features, enhancing clarity on system capabilities and workflows. Adjust values.yaml for image tag and replica count, and improve code documentation across various modules for better maintainability.
99 lines
3.6 KiB
Python
99 lines
3.6 KiB
Python
from os import getenv
|
|
from typing import Any
|
|
|
|
|
|
def build_postgres_config() -> dict[str, Any]:
|
|
"""
|
|
Build PostgreSQL connection configuration from environment variables.
|
|
|
|
Returns:
|
|
dict[str, Any]: PostgreSQL configuration dictionary with keys:
|
|
- host: Database hostname (default: localhost)
|
|
- port: Database port (default: 5432)
|
|
- user: Database username (default: sientia)
|
|
- password: Database password (default: sientia)
|
|
- dbname: Database name (default: sientia)
|
|
- min_connections: Minimum connection pool size (default: 5)
|
|
- max_connections: Maximum connection pool size (default: 20)
|
|
"""
|
|
return {
|
|
'host': getenv('POSTGRES_HOST', 'localhost'),
|
|
'port': int(getenv('POSTGRES_PORT', '5432')),
|
|
'user': getenv('POSTGRES_USER', 'sientia'),
|
|
'password': getenv('POSTGRES_PASSWORD', 'sientia'),
|
|
'dbname': getenv('POSTGRES_DBNAME', 'sientia'),
|
|
'min_connections': int(getenv('POSTGRES_MIN_CONNECTIONS', '5')),
|
|
'max_connections': int(getenv('POSTGRES_MAX_CONNECTIONS', '20'))
|
|
}
|
|
|
|
|
|
def build_kafka_config() -> dict[str, Any]:
|
|
"""
|
|
Build Kafka configuration from environment variables.
|
|
|
|
Returns:
|
|
dict[str, Any]: Kafka configuration dictionary with keys:
|
|
- bootstrap_servers: Kafka broker addresses (default: localhost:9092)
|
|
- polling_time: Consumer polling interval in milliseconds (default: 1000)
|
|
- group_id: Consumer group identifier (default: scouter-group)
|
|
"""
|
|
return {
|
|
'bootstrap_servers': getenv('KAFKA_BOOTSTRAP_SERVERS', 'localhost:9092'),
|
|
'polling_time': int(getenv('KAFKA_POLLING_TIME', '1000')),
|
|
'group_id': 'scouter-group'
|
|
}
|
|
|
|
|
|
def build_redis_config() -> dict[str, Any]:
|
|
"""
|
|
Build Redis connection configuration from environment variables.
|
|
|
|
Returns:
|
|
dict[str, Any]: Redis configuration dictionary with keys:
|
|
- host: Redis server hostname (default: localhost)
|
|
- port: Redis server port (default: 6379)
|
|
- username: Redis authentication username (default: None)
|
|
- password: Redis authentication password (default: None)
|
|
"""
|
|
return {
|
|
'host': getenv('REDIS_HOST', 'localhost'),
|
|
'port': int(getenv('REDIS_PORT', '6379')),
|
|
'username': getenv('REDIS_USERNAME', None),
|
|
'password': getenv('REDIS_PASSWORD', None)
|
|
}
|
|
|
|
|
|
def build_mongodb_config() -> dict[str, Any]:
|
|
"""
|
|
Build MongoDB connection configuration from environment variables.
|
|
|
|
Returns:
|
|
dict[str, Any]: MongoDB configuration dictionary with keys:
|
|
- connection_string: Complete MongoDB connection URI
|
|
- database_name: Target database name (default: sientia)
|
|
"""
|
|
username = getenv('MONGODB_USERNAME', 'sientia')
|
|
password = getenv('MONGODB_PASSWORD', 'sientia')
|
|
uri = getenv('MONGODB_URL', 'localhost:27017')
|
|
|
|
connection_string = f'mongodb://{username}:{password}@{uri}'
|
|
return {
|
|
'connection_string': connection_string,
|
|
'database_name': getenv('MONGODB_DATABASE_NAME', 'sientia')
|
|
}
|
|
|
|
|
|
def build_druid_config() -> dict[str, Any]:
|
|
"""
|
|
Build Apache Druid connection configuration from environment variables.
|
|
|
|
Returns:
|
|
dict[str, Any]: Druid configuration dictionary with keys:
|
|
- host: Druid server hostname (default: localhost)
|
|
- port: Druid server port (default: 8082)
|
|
"""
|
|
return {
|
|
'host': getenv('DRUID_HOST', 'localhost'),
|
|
'port': int(getenv('DRUID_PORT', '8082')),
|
|
}
|