microservice-chassis-grupo2 0.1.3__tar.gz → 0.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of microservice-chassis-grupo2 might be problematic. Click here for more details.
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/PKG-INFO +1 -1
- microservice_chassis_grupo2-0.1.5/README.md +44 -0
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/microservice_chassis_grupo2/core/dependencies.py +1 -1
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/microservice_chassis_grupo2/core/rabbitmq_core.py +2 -0
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/microservice_chassis_grupo2.egg-info/PKG-INFO +1 -1
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/setup.py +1 -1
- microservice_chassis_grupo2-0.1.3/README.md +0 -1
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/microservice_chassis_grupo2/__init__.py +0 -0
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/microservice_chassis_grupo2/core/__init__.py +0 -0
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/microservice_chassis_grupo2/core/config.py +0 -0
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/microservice_chassis_grupo2/core/router_utils.py +0 -0
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/microservice_chassis_grupo2/core/security.py +0 -0
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/microservice_chassis_grupo2/sql/__init__.py +0 -0
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/microservice_chassis_grupo2/sql/database.py +0 -0
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/microservice_chassis_grupo2/sql/models.py +0 -0
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/microservice_chassis_grupo2.egg-info/SOURCES.txt +0 -0
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/microservice_chassis_grupo2.egg-info/dependency_links.txt +0 -0
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/microservice_chassis_grupo2.egg-info/top_level.txt +0 -0
- {microservice_chassis_grupo2-0.1.3 → microservice_chassis_grupo2-0.1.5}/setup.cfg +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# 🧩 Microservice Chassis Grupo 2
|
|
2
|
+
|
|
3
|
+
**Repository link:** https://github.com/Grupo-MACC/Chassis
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Functionalities
|
|
8
|
+
|
|
9
|
+
This repository provides a **shared chassis** for microservices, containing configuration, database management, authentication, messaging, and helper utilities.
|
|
10
|
+
It allows microservices to reuse common functionalities such as database connections, JWT validation, RabbitMQ communication, and standardized base models.
|
|
11
|
+
|
|
12
|
+
Below is a detailed list of the available functionalities:
|
|
13
|
+
|
|
14
|
+
| **Module** | **Functionality** | **Description** |
|
|
15
|
+
|-------------|------------------|-----------------|
|
|
16
|
+
| `core/config.py` | **Settings Management** | Centralized configuration for the chassis. Defines constants like the encryption algorithm (`RS256`), RabbitMQ connection parameters (`RABBITMQ_HOST`), and exchange name (`broker`). |
|
|
17
|
+
| `core/security.py` | **Token Decoding and Verification** | Handles JWT decoding using a public RSA key. Validates tokens and raises appropriate HTTP errors if invalid or missing. |
|
|
18
|
+
| `core/dependencies.py` | **Database Session & Authentication Dependency** | Provides FastAPI dependencies to manage asynchronous database sessions (`get_db`) and current user retrieval (`get_current_user`) from a JWT token. |
|
|
19
|
+
| `core/rabbitmq.py` | **RabbitMQ Channel & Exchange Management** | Creates asynchronous connections to RabbitMQ using `aio_pika`. Declares durable topic exchanges for inter-service communication. |
|
|
20
|
+
| `core/utils.py` | **Helper Functions and Service URLs** | Defines service URLs (order, machine, delivery, payment, auth) and provides error handling utilities with standardized logging (`raise_and_log_error`). |
|
|
21
|
+
| `sql/database.py` | **Database Engine & Session Configuration** | Configures SQLAlchemy’s asynchronous engine and sessionmaker. Supports `SQLALCHEMY_DATABASE_URL` via environment variable (defaults to SQLite). |
|
|
22
|
+
| `sql/base_class.py` | **Base Model for ORM Classes** | Provides a reusable abstract base class (`BaseModel`) for all database models, including timestamp columns (`creation_date`, `update_date`) and helper methods for converting models to dictionaries. |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Functionalities per Microservice
|
|
27
|
+
|
|
28
|
+
| **Microservice** | **Used Functionalities** |
|
|
29
|
+
|------------------|--------------------------|
|
|
30
|
+
| `payment` | `core/config`, `core/security`, `core/dependencies`, `core/rabbitmq`, `core/utils`, `sql/database`, `sql/base_class` |
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Summary
|
|
35
|
+
|
|
36
|
+
This chassis allows the `payment` microservice (and potentially others in the future) to operate with consistent patterns for:
|
|
37
|
+
- Secure token validation.
|
|
38
|
+
- Standardized database access and sessions.
|
|
39
|
+
- Centralized configuration.
|
|
40
|
+
- RabbitMQ-based inter-service communication.
|
|
41
|
+
- Common helper utilities and error management.
|
|
42
|
+
- Unified base ORM models.
|
|
43
|
+
|
|
44
|
+
It provides a robust foundation for building scalable and maintainable microservices within the system.
|
|
@@ -9,7 +9,7 @@ auth_scheme = HTTPBearer()
|
|
|
9
9
|
# Database #########################################################################################
|
|
10
10
|
async def get_db():
|
|
11
11
|
"""Generates database sessions and closes them when finished."""
|
|
12
|
-
from sql.database import SessionLocal
|
|
12
|
+
from microservice_chassis_grupo2.sql.database import SessionLocal
|
|
13
13
|
logger.debug("Getting database SessionLocal")
|
|
14
14
|
db = SessionLocal()
|
|
15
15
|
try:
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from aio_pika import connect_robust, ExchangeType
|
|
2
2
|
from microservice_chassis_grupo2.core.config import settings
|
|
3
3
|
|
|
4
|
+
PUBLIC_KEY_PATH = "/home/pyuser/code/auth_public.pem"
|
|
5
|
+
|
|
4
6
|
async def get_channel():
|
|
5
7
|
connection = await connect_robust(settings.RABBITMQ_HOST)
|
|
6
8
|
channel = await connection.channel()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# Chassis
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|