|
9 | 9 |
|
10 | 10 | from collections.abc import Mapping |
11 | 11 | from copy import deepcopy |
| 12 | +from typing import Literal |
| 13 | + |
12 | 14 | from karapace.core.constants import DEFAULT_AIOHTTP_CLIENT_MAX_SIZE, DEFAULT_PRODUCER_MAX_REQUEST, DEFAULT_SCHEMA_TOPIC |
13 | 15 | from karapace.core.typing import ElectionStrategy, NameStrategy |
14 | 16 | from karapace.core.utils import json_encode |
15 | 17 | from pathlib import Path |
16 | | -from pydantic import BaseModel, ImportString |
| 18 | +from pydantic import BaseModel, ImportString, field_validator |
17 | 19 | from pydantic_settings import BaseSettings, SettingsConfigDict |
18 | 20 |
|
19 | 21 | import enum |
@@ -118,7 +120,7 @@ class Config(BaseSettings): |
118 | 120 | topic_name: str = DEFAULT_SCHEMA_TOPIC |
119 | 121 | metadata_max_age_ms: int = 60000 |
120 | 122 | admin_metadata_max_age: int = 5 |
121 | | - producer_acks: int = 1 |
| 123 | + producer_acks: int | Literal["all"] = 1 |
122 | 124 | producer_compression_type: str | None = None |
123 | 125 | producer_count: int = 5 |
124 | 126 | producer_linger_ms: int = 100 |
@@ -156,6 +158,12 @@ def get_advertised_hostname(self) -> str: |
156 | 158 | def get_address(self) -> str: |
157 | 159 | return f"{self.host}:{self.port}" |
158 | 160 |
|
| 161 | + @field_validator("producer_acks", mode="before") |
| 162 | + def normalize_producer_acks(cls, v): |
| 163 | + if isinstance(v, str) and v.lower() == "all": |
| 164 | + return -1 |
| 165 | + return v |
| 166 | + |
159 | 167 | def get_rest_base_uri(self) -> str: |
160 | 168 | return ( |
161 | 169 | self.rest_base_uri |
|
0 commit comments