Skip to content

Gateway#3

Merged
Jenish-1235 merged 20 commits intodevfrom
gateway
Dec 19, 2025
Merged

Gateway#3
Jenish-1235 merged 20 commits intodevfrom
gateway

Conversation

@Jenish-1235
Copy link
Copy Markdown
Contributor

This pull request introduces several improvements and updates across the codebase, focusing on upgrading the Python version, simplifying health checks, improving Redis and database connection handling, and enhancing configuration flexibility. The changes also include code cleanup and minor refactoring for better maintainability and clarity.

Environment and Dependency Upgrades:

  • Upgraded the base Python version from 3.11 to 3.13.7 in both the Dockerfile and GitHub Actions CI workflow for consistency and access to the latest language features and performance improvements. [1] [2] [3] [4]

Infrastructure and Service Integration:

  • Added a Redis service to the CI workflow using the redis:7-alpine Docker image, enabling integration tests that require Redis.

Configuration and Connection Handling:

  • Enhanced the Settings class to support an explicit REDIS_URL environment variable, allowing more flexible Redis connection configuration, especially in containerized environments. Also added a redis_max_connections setting. [1] [2]
  • Simplified and refactored health and readiness checks to directly use the ping() methods of the database and Redis clients, removing the need for separate verification functions. [1] [2] [3]
  • Removed unused or redundant imports and exports related to database and Redis verification from the core/__init__.py module. [1] [2] [3]

Code Cleanup and Minor Refactoring:

  • Made minor code style and formatting improvements throughout the codebase, such as simplifying string formatting, logging statements, and function signatures for improved readability and maintainability. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]
  • Updated the AppState class to include a pod_id attribute for distributed connection management and changed the Redis client cleanup method from close() to disconnect(). [1] [2]
  • Improved refresh token caching logic to ensure the cache TTL does not exceed the token's expiration.

These changes collectively improve the project's maintainability, deployment flexibility, and reliability, especially in containerized and cloud environments.

harii55 and others added 20 commits December 13, 2025 03:17
…g for audio/video streams, include comprehensive tests for gateway components.
…or Redis settings, and add Redis service to Docker Compose. Include tests for Redis client functionality.
- Add secondary index (user_sessions:{user_id} SET) for O(1) lookups
- Implement grace period (10-min TTL) on disconnect for session reuse
- Throttle activity updates to 5 minutes (16,500x reduction)
- Add comprehensive integration tests for end-to-end verification
- Ensure no ghost sessions (both keys cleaned up properly)

Performance:
- Activity updates: 100 ops/sec → 0.006 ops/sec
- User sessions lookup: O(n) SCAN → O(k) SET lookup
- Implement SessionCleanupService to periodically clean up stale session IDs from Redis.
- Integrate session cleanup into the application lifespan management.
- Add distributed locking mechanism to prevent concurrent cleanup operations.
- Enhance Redis client with batch operations for efficient key existence checks.
- Introduce comprehensive unit and integration tests for the cleanup service and its interactions with Redis.

This update improves session management reliability and ensures stale sessions are efficiently removed, enhancing overall application performance.
- Add redis_max_connections setting to configure maximum Redis connections.
- Refactor main.py to initialize Redis client with new connection settings.
- Update health check endpoints to verify Redis connection status.
- Remove unused database and Redis client creation functions.
- Introduce idempotent session keys for WebSocket connections to improve session management.
- Implement batch operations in Redis client for efficient session handling.
- Update tests to reflect changes in session management and Redis interactions.

These enhancements improve the application's performance and reliability in managing Redis connections and user sessions.
…ultiple files

- Simplified string formatting in config.py, main.py, and various model files for improved readability.
- Refactored method signatures in auth.py, keyvault.py, and test files to enhance consistency and clarity.
- Cleaned up exception representation in exceptions.py for better debugging output.
…, atomic pipelines, and improved connection tracking; fix test mocks
@Jenish-1235 Jenish-1235 merged commit eb6c434 into dev Dec 19, 2025
3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants