SIENTIAPDE-1478

Refactor PIWebAPIClient and Update Configuration Imports

- Removed outdated PostgreSQL, Redis, MongoDB, and API configuration functions from connectors_config.py.
- Deleted the pi_web_api_client.py file as part of the refactor.
- Updated imports in worker.py and api.py to use the new repository structure.
- Cleaned up scenarios.md by removing obsolete scenarios related to unique constraint violations.
- Commented out the specific version of the sientia-dataops-library in requirements.txt for flexibility.
This commit is contained in:
vitor-aignosi
2026-01-08 12:41:53 -03:00
parent 9988720421
commit cf7f9fb63c
9 changed files with 6 additions and 484 deletions

View File

@@ -2,31 +2,6 @@ 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.
@@ -42,74 +17,3 @@ def build_kafka_config() -> dict[str, Any]:
'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_api_config() -> dict[str, Any]:
"""
Build API connection configuration from environment variables.
Returns:
dict[str, Any]: API configuration dictionary with keys:
- base_url: API base URL (default: https://pi.example.com)
- auth_type: API authentication type (default: basic)
- auth_token: API authentication token (default: None)
"""
return {
'base_url': getenv('PI_WEB_API_BASE_URL', 'https://pi.example.com'),
'auth_type': getenv('PI_WEB_API_AUTH_TYPE', 'basic'),
'auth_token': getenv('PI_WEB_API_AUTH_TOKEN', None),
}
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')),
}