FireFeed Core
Core utilities and models for FireFeed microservices architecture.
FireFeed Core is a shared library that provides common components for all FireFeed microservices, ensuring consistency, security, and reliability across the distributed system.
🚀 Features
- API Client: Robust HTTP client with authentication, retry policies, circuit breaker, and rate limiting
- JWT Authentication: Service-to-service authentication with token management
- Exception Handling: Comprehensive exception hierarchy for consistent error handling
- Configuration: Pydantic-based configuration management
- Interfaces: Abstract interfaces for service contracts
- Utilities: Common utility functions and helpers
📦 Installation
pip install firefeed-core
🔧 Quick Start
Basic API Client Usage
import asyncio
from firefeed_core import APIClient
async def main():
# Initialize API client
async with APIClient(
base_url="http://firefeed-api:8000",
token="your-jwt-token",
service_id="firefeed-rss-parser"
) as client:
# Make authenticated requests
feeds = await client.get("/api/v1/internal/rss/feeds")
print(f"Found {len(feeds)} feeds")
# Create new RSS item
new_item = await client.post("/api/v1/internal/rss/items", {
"title": "Test Article",
"content": "This is a test article",
"feed_id": 123
})
asyncio.run(main())
JWT Token Management
from firefeed_core import ServiceTokenManager
# Generate token for service
token_manager = ServiceTokenManager(
secret_key="your-secret-key",
issuer="firefeed-api"
)
token = token_manager.generate_service_token(
service_id="firefeed-rss-parser",
audience="firefeed-api",
scopes=["rss:read", "rss:write"]
)
# Verify token
payload = token_manager.verify_token(token)
print(f"Token for service: {payload.sub}")
Exception Handling
from firefeed_core import APIException, NotFoundException
try:
result = await client.get("/api/v1/internal/rss/feeds/999")
except NotFoundException as e:
print(f"Feed not found: {e.message}")
except APIException as e:
print(f"API error: {e.message}")
🔐 Authentication
FireFeed Core uses JWT tokens for service-to-service authentication. Each service needs:
- Service Token: JWT token with appropriate scopes
- Service ID: Unique identifier for the service
- Secret Key: Shared secret for token verification
Environment Configuration
Each service should have its own .env file:
# firefeed-rss-parser/.env
FIREFEED_API_URL=http://firefeed-api:8000
FIREFEED_API_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
FIREFEED_RSS_PARSER_SERVICE_ID=rss-parser
# firefeed-telegram-bot/.env
FIREFEED_API_URL=http://firefeed-api:8000
FIREFEED_API_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
FIREFEED_TELEGRAM_BOT_SERVICE_ID=telegram-bot
Token Scopes
Services can be granted specific scopes for different operations:
rss:read- Read RSS datarss:write- Create/modify RSS datausers:read- Read user datausers:write- Modify user datacategories:read- Read categoriescategories:write- Modify categories
🛠️ Advanced Features
Circuit Breaker
Automatically prevents requests to failing services:
from firefeed_core import APIClient
client = APIClient(
base_url="http://service:8000",
token="token",
service_id="my-service",
circuit_breaker_failure_threshold=5,
circuit_breaker_timeout=60
)
Retry Policies
Configurable retry with exponential backoff:
client = APIClient(
base_url="http://service:8000",
token="token",
service_id="my-service",
max_retries=3
)
Rate Limiting
Prevents API abuse:
client = APIClient(
base_url="http://service:8000",
token="token",
service_id="my-service",
rate_limit_requests=100,
rate_limit_window=60
)
📊 Monitoring
Each API client provides comprehensive statistics:
stats = client.get_stats()
print(f"Circuit breaker state: {stats['circuit_breaker']['state']}")
print(f"Rate limit usage: {stats['rate_limiter']['current_requests']}")
🏗️ Architecture
FireFeed Core follows these principles:
- API-First: All services communicate via HTTP APIs only
- Zero Direct Database Access: Services never access databases directly
- Token-Based Security: All inter-service communication is authenticated
- Fault Tolerance: Circuit breakers, retries, and rate limiting
- Consistent Error Handling: Standardized exception hierarchy
Service Communication Flow
┌─────────────────────┐ JWT Token ┌─────────────────────┐
│ firefeed-rss-parser│ ──────────────→ │ firefeed-api │
│ (Dumb Service) │ │ (Smart Service) │
│ │ ←────────────── │ │
│ - RSS Processing │ HTTP API │ - Database Access │
│ - No DB Access │ │ - Business Logic │
└─────────────────────┘ └─────────────────────┘
🧪 Testing
# Install test dependencies
pip install -e ".[test]"
# Run tests
pytest
# Run with coverage
pytest --cov=firefeed_core
📝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
📄 License
MIT License - see LICENSE file for details.
🔗 Related Projects
- FireFeed API - Main API service
- FireFeed RSS Parser - RSS processing service
- FireFeed Telegram Bot - Telegram bot service
Note: This is a core library intended for use within the FireFeed microservices ecosystem.
Metadata
Release files for firefeed-core 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| firefeed_core-1.0.6.tar.gz | 110.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| firefeed_core-1.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 248.3 kB
Release files / firefeed_core-1.0.6.tar.gz
| Download URL | firefeed_core-1.0.6.tar.gz |
|---|---|
| Size | 110.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2033c2469589e6205ce4fe229d5d31dd0763608498e2881d944c2df704388400
|
|
BLAKE2b-256 checksum How to use checksums |
8ef973fc6c6a1d22c4d7f5a527e82625e0c0ae27be0a182cacd77527c6a40852
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 19, 2026.
Transparency logRelease files / firefeed_core-1.0.6-py3-none-any.whl
| Download URL | firefeed_core-1.0.6-py3-none-any.whl |
|---|---|
| Size | 137.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a09ba7242fa0de2028192e5ccf20ea8f2981c5786e44ffbefcedf3bfe12fe41
|
|
BLAKE2b-256 checksum How to use checksums |
733b82b2465cb23b940f619045def913d1ed64440e0b360a624673de1558cd4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 19, 2026.
Transparency log