Shared utility library for Cloudscaile extension features, providing Kafka integration and utilities
Project description
platform-ext-utils
Shared utility library for Cloudscaile extension features, providing Kafka integration, environment configuration management, and external connectivity utilities.
Features
- Kafka Service: Simplified Kafka producer and consumer interface with Sasl support
- Environment Management: Centralized configuration via environment variables
- Logger: Pre-configured logging for consistent application logs
- External Connectivity: Internal HTTP client instances for inter-service communication
Installation
pip install platform-ext-utils
Requirements
- Python >= 3.9
- confluent-kafka >= 2.4
- pydantic >= 2.0
- pydantic-settings >= 2.0
- httpx >= 0.25
Configuration
All configuration is done via environment variables:
# Kafka Configuration
KAFKA_REQUIRED=
KAFKA_CLIENT_ID=
KAFKA_BROKERS=
KAFKA_GROUP_ID=
KAFKA_CONSUMER_TOPIC=
KAFKA_PRODUCER_TOPIC=
# Optional: Kafka SASL Authentication
KAFKA_SASL=
KAFKA_SASL_USERNAME=
KAFKA_SASL_PASSWORD=
# Tenant Configuration
TENANT_NAME=
EXTENSION_NAME=
Usage
Producing Messages
from py_utils import produce_message
produce_message(
{"event": "user_created", "userId": "123"},
topic="user-events"
)
Consuming Messages
from py_utils import kafka_service
def handle_message(event):
print("Received:", event)
if kafka_service:
kafka_service.consume(callback=handle_message)
The callback receives:
{
"queueName": "<topic>",
"partition": 0,
"offset": 42,
"message": "<decoded string>",
"timestamp": (<type>, <value>)
}
Using Logger
from py_utils.utils.logger import logger
logger.info("Application started")
logger.error("An error occurred")
External Connectivity
from py_utils import internal_axios_instances
# Use pre-configured HTTP clients for inter-service communication
License
Apache License 2.0
Author
Cloudscaile Engineering
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file platform_ext_utils-0.0.1.tar.gz.
File metadata
- Download URL: platform_ext_utils-0.0.1.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc42fd5287a5f2af222ddee481880c3c95fd88e82b6d450e70e3e97b03bafdac
|
|
| MD5 |
1b8688112c22797a74691c26f38fa627
|
|
| BLAKE2b-256 |
d8ee09a0742c3f85eeca7b4bae4068ed0304b886c0b0ad5e1290f78b545d96c0
|
File details
Details for the file platform_ext_utils-0.0.1-py3-none-any.whl.
File metadata
- Download URL: platform_ext_utils-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0d97de98bbf2947b21cfff3a59bd28622c5d80464f86f6ebd3059f0c82744ab
|
|
| MD5 |
9fe6caf547bd61a43bdd58faf37b2eb5
|
|
| BLAKE2b-256 |
e153fa9c1aa3260fa6c594477f79b7a4ac997a5439e6ac3782d1f06a342902e5
|