fix(chalice): configurable CH config
This commit is contained in:
parent
65f3f36831
commit
44b2838ed7
3 changed files with 17 additions and 2 deletions
|
|
@ -19,13 +19,16 @@ class ClickHouseClient:
|
|||
__client = None
|
||||
|
||||
def __init__(self):
|
||||
extra_args = {}
|
||||
if config("CH_COMPRESSION", cast=bool, default=True):
|
||||
extra_args["compression"] = "lz4"
|
||||
self.__client = clickhouse_driver.Client(host=config("ch_host"),
|
||||
database=config("ch_database", default="default"),
|
||||
user=config("ch_user", default="default"),
|
||||
password=config("ch_password", default=""),
|
||||
port=config("ch_port", cast=int),
|
||||
settings=settings,
|
||||
compression='lz4') \
|
||||
**extra_args) \
|
||||
if self.__client is None else self.__client
|
||||
|
||||
def __enter__(self):
|
||||
|
|
|
|||
|
|
@ -74,4 +74,5 @@ ASSIST_JWT_EXPIRATION=144000
|
|||
ASSIST_JWT_SECRET=
|
||||
KAFKA_SERVERS=kafka.db.svc.cluster.local:9092
|
||||
KAFKA_USE_SSL=false
|
||||
SCH_DELETE_DAYS=30
|
||||
SCH_DELETE_DAYS=30
|
||||
CH_COMPRESSION=true
|
||||
|
|
@ -21,6 +21,17 @@ class Permissions(str, Enum):
|
|||
class CurrentContext(schemas.CurrentContext):
|
||||
permissions: List[Optional[Permissions]] = Field(...)
|
||||
|
||||
@root_validator(pre=True)
|
||||
def remove_unsupported_perms(cls, values):
|
||||
if values.get("permissions") is not None:
|
||||
perms = []
|
||||
_perms = [item.value for item in Permissions]
|
||||
for p in values["permissions"]:
|
||||
if p in _perms:
|
||||
perms.append(p)
|
||||
values["permissions"] = perms
|
||||
return values
|
||||
|
||||
|
||||
class RolePayloadSchema(BaseModel):
|
||||
name: str = Field(..., min_length=1, max_length=40)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue