Repository navigation
v2.0.0
[2.0.0] - 2025-12-10
⚠️ BREAKING CHANGES
This release contains breaking changes that require migration for Redis storage users.
- Redis storage now requires
redis_clientparameter - removed**kwargssupport for Redis connection parameters - Redis keys format changed - v1.x data is incompatible with v2.0.0 (migration required)
CallGate.from_file()requiresredis_clientparameter when restoring Redis storage gates
Added
- Redis Cluster Support: CallGate now supports Redis clusters in addition to single Redis instances
- Pre-initialized Redis Client Support: New
redis_clientparameter accepts pre-initializedRedisorRedisClusterclients - Enhanced Type Safety: Better type annotations and IDE support for Redis configurations
- New Error Type:
CallGateRedisConfigurationErrorfor Redis configuration issues - Code examples
Changed
- Redis Storage Initialization:
redis_clientparameter is now required (removed**kwargs) - Redis Keys Format: Keys now use hash tags for cluster support (
{gate_name}instead ofgate_name) - Improved Documentation: All docstrings converted to English with RST format
- Test Infrastructure: Added comprehensive cluster tests with fault tolerance scenarios
- Makefile Enhancements: Added cluster test targets for all Python versions (3.9-3.14)
Fixed
- Connection Validation: Added ping() validation for Redis clients during CallGate initialization
- Serialization Handling: Improved serialization for RedisStorage with pre-initialized clients
- Docker Compose Configuration: Fixed cluster configuration with proper network settings
- Multiprocessing Support: Fixed pickling issues for all storage types
Removed
**kwargsin CallGate.init(): No longer accepts Redis connection parameters (host, port, db, etc.)- Legacy Redis Configuration: Removed automatic Redis client creation from kwargs
- Old Redis Keys Format: Keys without hash tags are no longer created
⚠️ MIGRATION GUIDE v1.x → v2.x
BREAKING CHANGES SUMMARY:
- Redis storage requires
redis_clientparameter (removed**kwargssupport) - Redis keys format changed - old v1.x data is incompatible with v2.x
CallGate.from_file()requiresredis_clientfor Redis storage
Data Migration for Redis Storage
Redis keys format has changed - old v1.x data will NOT be accessible in v2.x
Step 1: Export data using v1.x and Python REPL
# Using CallGate v1.x
>>> from call_gate import CallGate
>>> redis_kwargs = {"host": "localhost", "port": 6379, "db": 15}
>>> gate = CallGate("my_gate", 60, 1, storage="redis", **redis_kwargs)
>>> gate.to_file("gate_backup.json")Step 2: Upgrade call-gate version
pip install call-gate --upgradeStep 3: Import data using v2.x and Python REPL
# Using CallGate v2.x
>>> from call_gate import CallGate
>>> from redis import Redis
>>> redis_kwargs = {"host": "localhost", "port": 6379, "db": 15}
>>> client = Redis(**redis_kwargs, decode_responses=True)
>>> gate = CallGate.from_file("gate_backup.json", storage="redis", redis_client=client) # Data is automatically written to Redis with new key format
>>> gate.stateIt's not recommended to insert
step 3into your business logic as it will rewrite your actual data from the file contents on each restart.
Why keys changed:
- v1.x keys:
gate_name,gate_name:sum,gate_name:timestamp - v2.x keys:
{gate_name},{gate_name}:sum,{gate_name}:timestamp - Hash tags
{...}ensure all keys for one gate are in the same Redis Cluster slot
API Changes
Before (v1.x):
redis_kwargs = {"host": "localhost", "port": 6379, "db": 15}
gate = CallGate(
name="my_gate",
gate_size=60,
frame_step=1,
storage="redis",
**redis_kwargs
)After (v2.x):
from redis import Redis
redis_kwargs = {"host": "localhost", "port": 6379, "db": 15}
client = Redis(**redis_kwargs, decode_responses=True)
gate = CallGate(
name="my_gate",
gate_size=60,
frame_step=1,
storage="redis",
redis_client=client # Required parameter
)Redis Cluster Usage
from redis import RedisCluster
from redis.cluster import ClusterNode
cluster_client = RedisCluster(
startup_nodes=[
ClusterNode("node1", 7001),
ClusterNode("node2", 7002),
ClusterNode("node3", 7003)
],
decode_responses=True,
skip_full_coverage_check=True
)
gate = CallGate(
name="cluster_gate",
gate_size=60,
frame_step=1,
storage="redis",
redis_client=cluster_client
)