reach_commons 0.18.37__py3-none-any.whl → 0.18.38__py3-none-any.whl

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.
@@ -133,7 +133,10 @@ class ReachRateLimiter:
133
133
  Loads config from Redis hash:
134
134
  limit_per_window, interval_seconds, jitter_seconds
135
135
 
136
- Uses short in-memory cache to avoid hammering Redis under high throughput.
136
+ Behavior:
137
+ - If config exists in Redis: read only (never overwrite).
138
+ - If config does NOT exist yet: seed Redis ONCE with defaults (so you can edit live).
139
+ - If Redis is unavailable: fallback to defaults (no writes).
137
140
  """
138
141
  now = self._now()
139
142
 
@@ -149,7 +152,18 @@ class ReachRateLimiter:
149
152
  jitter = self.default_jitter
150
153
 
151
154
  try:
152
- raw = self.redis.hgetall(self._cfg_key()) or {}
155
+ cfg_key = self._cfg_key()
156
+ raw = self.redis.hgetall(cfg_key) or {}
157
+
158
+ # If config was never created, seed it once with defaults
159
+ if not raw:
160
+ rc = self.redis.redis_connection
161
+ rc.hsetnx(cfg_key, "limit_per_window", str(self.default_limit))
162
+ rc.hsetnx(cfg_key, "interval_seconds", str(self.default_interval))
163
+ rc.hsetnx(cfg_key, "jitter_seconds", str(self.default_jitter))
164
+
165
+ # Re-read after seeding (so we now depend on Redis config)
166
+ raw = self.redis.hgetall(cfg_key) or {}
153
167
 
154
168
  # raw typically has bytes keys/values
155
169
  limit = self._parse_int(
@@ -162,7 +176,7 @@ class ReachRateLimiter:
162
176
  raw.get(b"jitter_seconds") or raw.get("jitter_seconds"), jitter
163
177
  )
164
178
 
165
- # Guard rails
179
+ # If someone puts garbage in Redis
166
180
  if limit <= 0:
167
181
  limit = self.default_limit
168
182
  if interval <= 0:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: reach_commons
3
- Version: 0.18.37
3
+ Version: 0.18.38
4
4
  Summary: Reach Commons is a versatile utility library designed to streamline and enhance development workflows within the Reach ecosystem.
5
5
  License: MIT
6
6
  Author: Engineering
@@ -21,7 +21,7 @@ reach_commons/reach_aws/dynamo_db.py,sha256=BL3QcKzx4uZic-Ui12tln_GMSKe297FdfyIz
21
21
  reach_commons/reach_aws/exceptions.py,sha256=x0RL5ktNtzxg0KykhEVWReBq_dEtciK6B2vMs_s4C9k,915
22
22
  reach_commons/reach_aws/firehose.py,sha256=1xFKLWMv3bNo3PPW5gtaL6NqzUDyVil6B768slj2wbY,5674
23
23
  reach_commons/reach_aws/kms.py,sha256=ZOfyJMQUgxJEojRoB7-aCxtATpNx1Ig522IUYH11NZ4,4678
24
- reach_commons/reach_aws/reach_rate_limiter.py,sha256=Z3gldy_EkkgVVl9rmc3t5xciccNPcRAiBY1stvr7YLw,7448
24
+ reach_commons/reach_aws/reach_rate_limiter.py,sha256=G0An8cD0BDU7ZAuK3Xxjy2_fo7nL3ksf1LBHBlnX65s,8201
25
25
  reach_commons/reach_aws/s3.py,sha256=2MLlDNFx0SROJBpE_KjJefyrB7lMqTlrYuRhSZx4iKs,3945
26
26
  reach_commons/reach_aws/sqs.py,sha256=IKKWrd-qbhMMVYUvGbaq1ouVRdx-0u-SqwYaTcp0tWY,21645
27
27
  reach_commons/reach_base_model.py,sha256=vgdGDcZr3iXMmyRhmBhOf_LKWB_6QzT3r_Yiyo6OmEk,3009
@@ -29,6 +29,6 @@ reach_commons/redis_manager.py,sha256=yRed53ZKlbIb6rZnL53D1F_aB-xWT3nbeUP2cqYzho
29
29
  reach_commons/sms_smart_encoding.py,sha256=92y0RmZ0l4ONHpC9qeO5KfViSNq64yE2rc7lhNDSZqE,1241
30
30
  reach_commons/utils.py,sha256=dMgKIGqTgoSItuBI8oz81gKtW3qi21Jkljv9leS_V88,8475
31
31
  reach_commons/validations.py,sha256=x_lkrtlrCAJC_f7mZb19JjfKFbYlPFv-P84K_lbZyYs,1056
32
- reach_commons-0.18.37.dist-info/METADATA,sha256=k2xckMxe857fXHo3p-lUKT0eWFwHmXTumKIqcI5M2GM,1863
33
- reach_commons-0.18.37.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
34
- reach_commons-0.18.37.dist-info/RECORD,,
32
+ reach_commons-0.18.38.dist-info/METADATA,sha256=Z_JM-y0N__A8dJQLCypLq5fXSAAaoV1P9BpehrClet8,1863
33
+ reach_commons-0.18.38.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
34
+ reach_commons-0.18.38.dist-info/RECORD,,