Exemplo n.º 1
0
class Config(BaseModel):

    host: str = "127.0.0.1"
    port: int = 9399
    protocol: module_from_string(asyncio.Protocol) = None
    backlog: int = 100
    limit: int = _DEFAULT_LIMIT
    server: module_from_string(Server) = Schema(Server, validate_always=True)

    class Config:
        extra = "allow"
Exemplo n.º 2
0
class MiddlewareConfig(BaseSettings):
    cls: module_from_string(Middleware) = None
    id: Union[int, None] = Schema(50, ge=0, le=100)

    class Config:
        env_prefix = ENV_PREFIX
        extra = "allow"
Exemplo n.º 3
0
class ExtensionConfig(BaseSettings):
    name: str
    cls: Union[module_from_string(Extension), None] = None

    class Config:
        env_prefix = ENV_PREFIX
        extra = "allow"
Exemplo n.º 4
0
class Config(BaseModel):

    host: str = monitor.MONITOR_HOST
    port: int = monitor.MONITOR_PORT
    console_port: int = monitor.CONSOLE_PORT
    console_enabled: bool = True
    monitor: module_from_string(Monitor) = Schema(Monitor,
                                                  validate_always=True)
Exemplo n.º 5
0
class EngineConfig(BaseSettings):

    MIDDLEWARES: List[MiddlewareConfig] = []
    EXTENSIONS: List[ExtensionConfig] = []
    read_max: int = 2**16 * 5
    dumb_connect_timeout: Union[None, float] = 3.0
    close_wait: Union[None, float] = 60.0
    close_channel_mode = CloseChannelMode.SERIAL
    channel_class: module_from_string(BaseChannel) = Schema(
        SerialStartupChannel, validate_always=True)

    @validator("dumb_connect_timeout", "close_wait", pre=True, always=True)
    def check_timeout(cls, v):
        if v is not None:
            if v < 0.0:
                raise ValueError("value must greater than 0.0")
        return v

    class Config:
        env_prefix = ENV_PREFIX
        extra = "allow"
        validate_all = True
Exemplo n.º 6
0
class Config(BaseModel):
    app: module_from_string(web.Application, instance=True)

    class Config:
        extra = "allow"