File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,6 +67,21 @@ def remotes_json_path(self) -> str:
6767 """Path to remotes.json configuration."""
6868 return os .path .join (self .base_dir , 'configs' , 'remotes.json' )
6969
70+ @property
71+ def rate_limiter_storage_uri (self ) -> str :
72+ """
73+ Storage URI for the rate limiter.
74+
75+ Uses CBS_RATE_LIMITER_STORAGE_URI env var if set and non-empty,
76+ otherwise falls back to redis backend. When using the redis backend,
77+ db index 1 is used to avoid conflicts with any other components that
78+ use db index 0.
79+ """
80+ uri = os .getenv ('CBS_RATE_LIMITER_STORAGE_URI' , '' ).strip ()
81+ if uri :
82+ return uri
83+ return f"redis://{ self .redis_host } :{ self .redis_port } /1"
84+
7085 @property
7186 def enable_inbuilt_builder (self ) -> bool :
7287 """Whether to enable the inbuilt builder."""
Original file line number Diff line number Diff line change 1010
1111settings = get_settings ()
1212
13- # We use the same redis instance which is used to store build metadata
14- # and other cached data. To keep that data separate, we use db-1 of the
15- # redis instance instead of the default db-0.
16- REDIS_DB_NUMBER = 1
1713limiter = Limiter (
1814 key_func = get_remote_address ,
19- storage_uri = f"redis:// { settings .redis_host } : { settings . redis_port } / { REDIS_DB_NUMBER } " ,
15+ storage_uri = settings .rate_limiter_storage_uri ,
2016 strategy = "fixed-window" ,
2117)
2218
You can’t perform that action at this time.
0 commit comments