Merge cluster to master #3
|
@ -16,7 +16,8 @@ ONE_MONTH_SECONDS = 2678000
|
||||||
|
|
||||||
class RedisCustom(Redis):
|
class RedisCustom(Redis):
|
||||||
"""
|
"""
|
||||||
A wrapper class to set prefixes to keys.
|
A simple wrapper class for Redis to create a "namespace" within a DB,
|
||||||
|
which simplyifies key management.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, prefix, **kwargs):
|
def __init__(self, prefix, **kwargs):
|
||||||
|
@ -250,4 +251,5 @@ class RedisCustom(Redis):
|
||||||
def zrem(self, name: KeyT, *values: FieldT):
|
def zrem(self, name: KeyT, *values: FieldT):
|
||||||
return self.redis.zrem(self._key(name), *values)
|
return self.redis.zrem(self._key(name), *values)
|
||||||
|
|
||||||
|
|
||||||
redis = RedisCustom('local_llm')
|
redis = RedisCustom('local_llm')
|
||||||
|
|
|
@ -23,6 +23,10 @@ def decrement_ip_count(client_ip: str, redis_key):
|
||||||
|
|
||||||
|
|
||||||
class RedisPriorityQueue:
|
class RedisPriorityQueue:
|
||||||
|
"""
|
||||||
|
A queue for a specific backend.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, name, db: int = 12):
|
def __init__(self, name, db: int = 12):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.redis = RedisCustom(name, db=db)
|
self.redis = RedisCustom(name, db=db)
|
||||||
|
@ -99,6 +103,10 @@ class RedisPriorityQueue:
|
||||||
|
|
||||||
|
|
||||||
class DataEvent:
|
class DataEvent:
|
||||||
|
"""
|
||||||
|
Class to simplify pub/sub communication between consumers and producers (MASTERS and SLAVES lololololol).
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, event_id=None):
|
def __init__(self, event_id=None):
|
||||||
self.event_id = event_id if event_id else str(uuid4())
|
self.event_id = event_id if event_id else str(uuid4())
|
||||||
self.redis = Redis(host='localhost', port=6379, db=14)
|
self.redis = Redis(host='localhost', port=6379, db=14)
|
||||||
|
@ -134,6 +142,10 @@ def decr_active_workers(selected_model: str, backend_url: str):
|
||||||
|
|
||||||
|
|
||||||
class PriorityQueue:
|
class PriorityQueue:
|
||||||
|
"""
|
||||||
|
Helper class to wrangler all the different queues.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, backends: set = None):
|
def __init__(self, backends: set = None):
|
||||||
"""
|
"""
|
||||||
Only have to load the backends once.
|
Only have to load the backends once.
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
def handle_server_error(e):
|
def handle_server_error(e):
|
||||||
print(e)
|
print(e)
|
||||||
return {'error': True}, 500
|
return {'error': True, 'code': 500, 'message': 'Internal Server Error :('}, 500
|
||||||
|
|
Reference in New Issue