feat: signin rate limit
This commit is contained in:
@@ -5,7 +5,13 @@ import logging
|
||||
|
||||
import redis
|
||||
|
||||
from open_webui.env import REDIS_SENTINEL_MAX_RETRY_COUNT
|
||||
from open_webui.env import (
|
||||
REDIS_CLUSTER,
|
||||
REDIS_SENTINEL_HOSTS,
|
||||
REDIS_SENTINEL_MAX_RETRY_COUNT,
|
||||
REDIS_SENTINEL_PORT,
|
||||
REDIS_URL,
|
||||
)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -108,6 +114,21 @@ def parse_redis_service_url(redis_url):
|
||||
}
|
||||
|
||||
|
||||
def get_redis_client(async_mode=False):
|
||||
try:
|
||||
return get_redis_connection(
|
||||
redis_url=REDIS_URL,
|
||||
redis_sentinels=get_sentinels_from_env(
|
||||
REDIS_SENTINEL_HOSTS, REDIS_SENTINEL_PORT
|
||||
),
|
||||
redis_cluster=REDIS_CLUSTER,
|
||||
async_mode=async_mode,
|
||||
)
|
||||
except Exception as e:
|
||||
log.debug(f"Failed to get Redis client: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def get_redis_connection(
|
||||
redis_url,
|
||||
redis_sentinels,
|
||||
|
||||
Reference in New Issue
Block a user