-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
87 lines (72 loc) · 2.84 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import re
from datetime import timedelta
from enum import Enum
from typing import Optional
from pydantic import BaseSettings, PostgresDsn
# If primary email matches, then add trace to logs
re_trace_email = re.compile(r".*\+trace-me-mozilla-.*@.*")
class LogLevel(str, Enum):
CRITICAL = "CRITICAL"
ERROR = "ERROR"
WARNING = "WARNING"
INFO = "INFO"
DEBUG = "DEBUG"
class Settings(BaseSettings):
db_url: PostgresDsn
db_pool_size: int = 5 # Default value from sqlalchemy
db_max_overflow: int = 10 # Default value from sqlalchemy
db_pool_timeout_in_seconds: int = 30 # Default value from sqlalchemy
db_pool_recycle_in_seconds: int = 900 # 15 minutes
secret_key: str
token_expiration: timedelta = timedelta(minutes=60)
server_prefix: str = "http://localhost:8000"
use_mozlog: bool = True
log_sqlalchemy: bool = False
logging_level: LogLevel = LogLevel.INFO
sentry_debug: bool = False
fastapi_env: Optional[str] = None
host: str = "0.0.0.0"
port: int = 8000
pubsub_audience: Optional[str] = None
pubsub_email: Optional[str] = None
pubsub_client: Optional[str] = None
# Background settings
acoustic_sync_feature_flag: bool = False # Enable/disable whole background sync job
acoustic_integration_feature_flag: bool = (
False # Enable/disable integration w/ Acoustic
)
acoustic_retry_limit: int = 6
acoustic_batch_limit: int = 20
acoustic_server_number: int = 6
acoustic_loop_min_secs: int = 5
acoustic_max_backlog: Optional[int] = None
acoustic_max_retry_backlog: Optional[int] = None
# Background settings, optional for API
acoustic_client_id: Optional[str] = None
acoustic_client_secret: Optional[str] = None
acoustic_refresh_token: Optional[str] = None
acoustic_main_table_id: Optional[int] = None
acoustic_newsletter_table_id: Optional[int] = None
acoustic_product_subscriptions_id: Optional[int] = None
prometheus_pushgateway_url: Optional[str] = None
background_healthcheck_path: Optional[str] = None
background_healthcheck_age_s: Optional[int] = None
acoustic_timeout_s: float = 5.0
class Config:
# The attributes of this class extract from the Env Var's that are `(prefix)(attr_name)` within the environment
env_prefix = "ctms_"
fields = {
"fastapi_env": {"env": "fastapi_env"},
"host": {"env": "host"},
"port": {"env": "port"},
}
class BackgroundSettings(Settings):
# Required background settings
acoustic_client_id: str
acoustic_client_secret: str
acoustic_refresh_token: str
acoustic_main_table_id: int
acoustic_newsletter_table_id: int
acoustic_product_subscriptions_id: int
prometheus_pushgateway_url: str
logging_level: LogLevel = LogLevel.DEBUG # Overloaded Default for Background Job