'commit'
This commit is contained in:
28
DouYin/apiproxy/common/config.py
Normal file
28
DouYin/apiproxy/common/config.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from typing import TypedDict, Optional
|
||||
from pathlib import Path
|
||||
import yaml
|
||||
|
||||
class DownloadConfig(TypedDict):
|
||||
max_concurrent: int
|
||||
chunk_size: int
|
||||
retry_times: int
|
||||
timeout: int
|
||||
|
||||
class LoggingConfig(TypedDict):
|
||||
level: str
|
||||
file_path: str
|
||||
max_size: int
|
||||
backup_count: int
|
||||
|
||||
class Config:
|
||||
def __init__(self, config_path: Path):
|
||||
with open(config_path) as f:
|
||||
self.config = yaml.safe_load(f)
|
||||
|
||||
@property
|
||||
def download_config(self) -> DownloadConfig:
|
||||
return self.config.get('download', {})
|
||||
|
||||
@property
|
||||
def logging_config(self) -> LoggingConfig:
|
||||
return self.config.get('logging', {})
|
||||
Reference in New Issue
Block a user