60 lines
1.4 KiB
Python
60 lines
1.4 KiB
Python
"""Shared constants for monitors and the consumer bot.
|
|
|
|
Holds Mongo connection settings, bot tokens, retry and timeout tuning,
|
|
client fingerprint identifiers, webhook routing maps, product status values,
|
|
and the expected error tuple used for known-failure handling.
|
|
"""
|
|
|
|
import asyncio
|
|
from enum import Enum
|
|
from json import JSONDecodeError
|
|
|
|
import aiohttp
|
|
import requests
|
|
from aioweb import AiowebError
|
|
from curl_cffi.requests.errors import RequestsError
|
|
from pymongo.errors import PyMongoError
|
|
|
|
MONGO_DATABASE_NAME = "tpv_woot"
|
|
MONGO_URL = (
|
|
"mongodb://tpv:n3%23QI07GnbZCbvGJ@zelda.disqualifier.me:27017/?authSource=tpv_woot"
|
|
)
|
|
LOGGING_LEVEL = "INFO"
|
|
LOGGERS = [
|
|
"discord",
|
|
"pymongo",
|
|
"aiohttp",
|
|
]
|
|
|
|
RETRY_LIMIT = 5
|
|
RETRY_WAIT = 3
|
|
CYCLE_DELAY = 0.30
|
|
MIN_BACKOFF_DELAY = 0.1
|
|
MAX_BACKOFF_DELAY = 2.0
|
|
FAILURE_DELAY = 3
|
|
|
|
TIMEOUT_SECONDS = 30
|
|
CLIENT_IDENTIFIERS = ["chrome", "chrome_android", "safari", "safari_ios"]
|
|
CLIENT_TIMEOUT = aiohttp.ClientTimeout(
|
|
total=TIMEOUT_SECONDS, sock_connect=30, sock_read=30
|
|
)
|
|
EXPECTED_TASK_ERRORS = (
|
|
RequestsError,
|
|
aiohttp.ClientError,
|
|
asyncio.TimeoutError,
|
|
requests.Timeout,
|
|
requests.HTTPError,
|
|
PyMongoError,
|
|
JSONDecodeError,
|
|
AiowebError,
|
|
)
|
|
|
|
|
|
class ProductStatus(str, Enum):
|
|
"""Lifecycle status for a monitored product document."""
|
|
|
|
PENDING = "pending"
|
|
SENT = "sent"
|
|
SKIPPED = "skipped"
|
|
FAILED = "failed"
|