-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added config structures, refactored attack handling a bit
- Loading branch information
1 parent
77ea300
commit 58ff213
Showing
9 changed files
with
89 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
from typing import List | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
def env_field(key: str) -> Field: | ||
return Field(default_factory=lambda: os.environ[key]) | ||
|
||
|
||
class Redis(BaseModel): | ||
host: str = env_field('REDIS_HOST') | ||
port: int = env_field('REDIS_PORT') | ||
password: str = env_field('REDIS_PASSWORD') | ||
db: int = 0 | ||
|
||
@property | ||
def url(self) -> str: | ||
return f'redis://:{self.password}@{self.host}:{self.port}/{self.db}' | ||
|
||
|
||
class WebCredentials(BaseModel): | ||
username: str = env_field('ADMIN_USERNAME') | ||
password: str = env_field('ADMIN_PASSWORD') | ||
|
||
|
||
class Database(BaseModel): | ||
host: str = env_field('POSTGRES_HOST') | ||
port: int = env_field('POSTGRES_PORT') | ||
user: str = env_field('POSTGRES_USER') | ||
password: str = env_field('POSTGRES_PASSWORD') | ||
dbname: str = env_field('POSTGRES_DB') | ||
|
||
|
||
class Celery(BaseModel): | ||
broker_url: str | ||
result_backend: str | ||
timezone: str | ||
|
||
worker_prefetch_multiplier: int = 1 | ||
|
||
redis_socket_timeout: int = 10 | ||
redis_socket_keepalive: bool = True | ||
redis_retry_on_timeout: bool = True | ||
|
||
accept_content: List[str] = ['pickle'] | ||
result_serializer: str = 'pickle' | ||
task_serializer: str = 'pickle' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,5 @@ def get_celery_app(): | |
], | ||
) | ||
|
||
app.conf.update(celery_config) | ||
app.conf.update(celery_config.dict()) | ||
return app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters