Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and reorganize grafana-docs-monitoring project for better maintainability #67

Open
Persimmonboy opened this issue Jun 18, 2024 · 0 comments
Assignees

Comments

@Persimmonboy
Copy link
Contributor

Persimmonboy commented Jun 18, 2024

This issue aims to refactor and reorganize the grafana-docs-monitoring repository to improve its maintainability and scalability. By implementing a more modular and configurable structure, we can simplify development and operational processes.

Tasks:

#### 1. Create Configuration Module
- Establish a config directory to house all environment-specific settings rather hardcoding them in scripts.
- Implement config/settings.py to manage settings from environment variables.
- Optionaly introduce .env files for different deployment environments to easily switch and manage configurations.

#### 2. Database Module Setup
- Set up a database module under the modules directory.
- Create for example connect_to_db() function in database.py to manage database connections using configurations from config/settings.py.

3. GitHub and Gitea API Module

  • Introduce a github_api.py and gitea_api.py file in the modules directory for GitHub and Gitea API interactions respectively.
  • Ensure all API interactions are wrapped in try-except blocks to log and manage exceptions effectively. This includes handling API rate limits, connection errors, and data processing errors.
  • Centralize common functionality such as error handling, logging, and retry logic in a utility module or class to be used by both API modules.

#### 4. Scripts for Routine Tasks
- Organize operational scripts in the scripts directory.
- Utilize functions from modules for tasks like updating database data or checking GitHub/Gitea issues.

5. Refactor Environment Handling in request_changes.py

  • Create a dictionary with environment names and their corresponding configurations.
  • Replace direct function calls with a for loop iterating over the dictionary.
  • Add logging to indicate the start and end of processing for each environment.
  • Rename main functions for better clarity.

6. Main Execution Script

  • Develop main.py at the project root as the entry point for running scripts.
  • Keep main.py simple, facilitating easy command-line or scheduled execution of tasks.

Expected Outcome:

Achieving these tasks will enhance the project's architecture for better maintainability and scalability, simplifying both development and operational processes.

Project Structure Proposal:

grafana-docs-monitoring/
|-- config/
|   |-- __init__.py
|   |-- settings.py
|-- modules/
|   |-- __init__.py
|   |-- database.py
|   |-- github_api.py
|   |-- gitea_api.py
|-- scripts/
|   |-- ecosystem_issues.py
|   |-- failed_zuul.py
|   |-- gitea_info.py
|   |-- github_info.py
|   |-- last_commit_info.py
|   |-- open_issues.py
|   |-- otc_services_dict.py
|   |-- request_changes.py
|   |-- scheduler.py
|-- dashboards/
|   |-- Last Docs Commit-1685007321105_ext.json
|   |-- Open Issues Eco-1707308045040.json
|   |-- Open Issues-1685006843303_ext.json
|   |-- Open PRs Dashboard-1686761368769.json
|-- main.py
|-- requirements.txt
|-- .env
|-- README.md
|-- tox.ini
|-- zuul.yaml
|-- Dockerfile
|-- LICENSE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants