2022-08-25 17:03:56 +00:00
|
|
|
"""MiniHuey singleton."""
|
2024-01-19 14:06:07 +00:00
|
|
|
from os import environ
|
|
|
|
from huey import RedisHuey
|
2022-08-25 17:03:56 +00:00
|
|
|
|
2024-01-19 14:06:07 +00:00
|
|
|
from selfprivacy_api.utils.redis_pool import RedisPool
|
2022-08-25 17:03:56 +00:00
|
|
|
|
2024-01-19 14:06:07 +00:00
|
|
|
HUEY_DATABASE_NUMBER = 10
|
2022-08-25 17:03:56 +00:00
|
|
|
|
2024-01-24 12:40:55 +00:00
|
|
|
|
2024-01-19 14:06:07 +00:00
|
|
|
def immediate() -> bool:
|
|
|
|
if environ.get("HUEY_QUEUES_FOR_TESTS"):
|
|
|
|
return False
|
|
|
|
if environ.get("TEST_MODE"):
|
|
|
|
return True
|
|
|
|
return False
|
2022-08-25 17:03:56 +00:00
|
|
|
|
2024-01-24 12:40:55 +00:00
|
|
|
|
2024-01-19 14:06:07 +00:00
|
|
|
# Singleton instance containing the huey database.
|
|
|
|
huey = RedisHuey(
|
2024-01-09 18:58:09 +00:00
|
|
|
"selfprivacy-api",
|
2024-01-19 14:06:07 +00:00
|
|
|
url=RedisPool.connection_url(dbnumber=HUEY_DATABASE_NUMBER),
|
|
|
|
immediate=immediate(),
|
2023-07-20 16:39:10 +00:00
|
|
|
utc=True,
|
2022-08-25 17:03:56 +00:00
|
|
|
)
|