dgkafka 1.0.0a4__py3-none-any.whl → 1.0.0a6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dgkafka/config.py +71 -68
- {dgkafka-1.0.0a4.dist-info → dgkafka-1.0.0a6.dist-info}/METADATA +1 -1
- {dgkafka-1.0.0a4.dist-info → dgkafka-1.0.0a6.dist-info}/RECORD +6 -6
- {dgkafka-1.0.0a4.dist-info → dgkafka-1.0.0a6.dist-info}/WHEEL +0 -0
- {dgkafka-1.0.0a4.dist-info → dgkafka-1.0.0a6.dist-info}/licenses/LICENSE +0 -0
- {dgkafka-1.0.0a4.dist-info → dgkafka-1.0.0a6.dist-info}/top_level.txt +0 -0
dgkafka/config.py
CHANGED
@@ -1,89 +1,92 @@
|
|
1
1
|
from typing import Literal, Optional
|
2
|
-
from pydantic import BaseModel, Field
|
2
|
+
from pydantic import BaseModel, Field, validator
|
3
|
+
from enum import Enum
|
4
|
+
|
5
|
+
|
6
|
+
class SecurityProtocol(str, Enum):
|
7
|
+
PLAINTEXT = "PLAINTEXT"
|
8
|
+
SSL = "SSL"
|
9
|
+
SASL_PLAINTEXT = "SASL_PLAINTEXT"
|
10
|
+
SASL_SSL = "SASL_SSL"
|
3
11
|
|
4
12
|
|
5
13
|
class KafkaConfig(BaseModel):
|
14
|
+
"""Base configuration for all Kafka clients"""
|
6
15
|
bootstrap_servers: str = Field(..., alias="bootstrap.servers",
|
7
|
-
|
8
|
-
security_protocol:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
description="Enable SSL certificate verification")
|
19
|
-
ssl_endpoint_identification_algorithm: Optional[str] = Field(default="https",
|
20
|
-
alias="ssl.endpoint.identification.algorithm",
|
21
|
-
description="Endpoint identification algorithm")
|
16
|
+
description="Comma-separated list of broker addresses")
|
17
|
+
security_protocol: SecurityProtocol = Field(default=SecurityProtocol.SSL,
|
18
|
+
alias="security.protocol")
|
19
|
+
ssl_cafile: Optional[str] = Field(default=None, alias="ssl.ca.location")
|
20
|
+
ssl_certfile: Optional[str] = Field(default=None, alias="ssl.certificate.location")
|
21
|
+
ssl_keyfile: Optional[str] = Field(default=None, alias="ssl.key.location")
|
22
|
+
ssl_check_hostname: bool = Field(default=True, alias="enable.ssl.certificate.verification")
|
23
|
+
ssl_password: Optional[str] = Field(default=None, alias="ssl.key.password")
|
24
|
+
|
25
|
+
def get(self) -> dict[str, Json]:
|
26
|
+
return self.model_dump(by_alias=True)
|
22
27
|
|
23
28
|
class Config:
|
24
29
|
validate_by_name = True
|
30
|
+
use_enum_values = True
|
25
31
|
extra = "forbid"
|
26
32
|
|
27
33
|
|
28
34
|
class ConsumerConfig(KafkaConfig):
|
29
|
-
|
30
|
-
|
31
|
-
enable_auto_commit: bool = Field(default=False, alias="enable.auto.commit"
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
description="Maximum records per poll")
|
38
|
-
session_timeout_ms: int = Field(default=10000, alias="session.timeout.ms",
|
39
|
-
description="Timeout for consumer session")
|
35
|
+
"""Configuration for basic Kafka consumer"""
|
36
|
+
group_id: str = Field(..., alias="group.id")
|
37
|
+
enable_auto_commit: bool = Field(default=False, alias="enable.auto.commit")
|
38
|
+
auto_offset_reset: Literal["earliest", "latest"] = Field(default="latest",
|
39
|
+
alias="auto.offset.reset")
|
40
|
+
session_timeout_ms: int = Field(default=10000, alias="session.timeout.ms")
|
41
|
+
max_poll_interval_ms: int = Field(default=300000, alias="max.poll.interval.ms")
|
42
|
+
fetch_max_bytes: int = Field(default=52428800, alias="fetch.max.bytes")
|
40
43
|
|
41
44
|
|
42
45
|
class ProducerConfig(KafkaConfig):
|
43
|
-
|
44
|
-
|
45
|
-
retries: int = Field(default=
|
46
|
-
linger_ms: int = Field(default=0, alias="linger.ms"
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
schema_registry_url: str = Field(..., alias="schema.registry.url"
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
class AvroProducerConfig(ProducerConfig, AvroConfigMixin):
|
72
|
-
value_subject_name_strategy: Optional[str] = Field(default=None,
|
73
|
-
alias="value.subject.name.strategy",
|
74
|
-
description="Strategy for subject name generation")
|
75
|
-
key_subject_name_strategy: Optional[str] = Field(default=None,
|
76
|
-
alias="key.subject.name.strategy",
|
77
|
-
description="Strategy for key subject name generation")
|
46
|
+
"""Configuration for basic Kafka producer"""
|
47
|
+
acks: Literal["all", "0", "1"] = Field(default="all")
|
48
|
+
retries: int = Field(default=0)
|
49
|
+
linger_ms: int = Field(default=0, alias="linger.ms")
|
50
|
+
compression_type: Literal["none", "gzip", "snappy", "lz4", "zstd"] = Field(
|
51
|
+
default="none", alias="compression.type")
|
52
|
+
batch_size: int = Field(default=16384, alias="batch.size")
|
53
|
+
max_in_flight: int = Field(default=1000000, alias="max.in.flight.requests.per.connection")
|
54
|
+
|
55
|
+
|
56
|
+
class AvroConsumerConfig(ConsumerConfig):
|
57
|
+
"""Configuration for Avro consumer with Schema Registry"""
|
58
|
+
schema_registry_url: str = Field(..., alias="schema.registry.url")
|
59
|
+
schema_registry_ssl_cafile: Optional[str] = Field(default=None,
|
60
|
+
alias="schema.registry.ssl.ca.location")
|
61
|
+
schema_registry_basic_auth_user_info: Optional[str] = Field(default=None,
|
62
|
+
alias="schema.registry.basic.auth.user.info")
|
63
|
+
specific_avro_reader: bool = Field(default=False, alias="specific.avro.reader")
|
64
|
+
|
65
|
+
|
66
|
+
class AvroProducerConfig(ProducerConfig):
|
67
|
+
"""Configuration for Avro producer with Schema Registry"""
|
68
|
+
schema_registry_url: str = Field(..., alias="schema.registry.url")
|
69
|
+
schema_registry_ssl_cafile: Optional[str] = Field(default=None,
|
70
|
+
alias="schema.registry.ssl.ca.location")
|
71
|
+
schema_registry_basic_auth_user_info: Optional[str] = Field(default=None,
|
72
|
+
alias="schema.registry.basic.auth.user.info")
|
73
|
+
max_schemas_per_subject: int = Field(default=1000, alias="max.schemas.per.subject")
|
78
74
|
|
79
75
|
|
80
76
|
class JsonConsumerConfig(ConsumerConfig):
|
81
|
-
|
82
|
-
|
83
|
-
encoding: str = Field(default="utf-8"
|
77
|
+
"""Configuration for JSON consumer"""
|
78
|
+
json_deserializer: Optional[str] = None # Custom deserializer function
|
79
|
+
encoding: str = Field(default="utf-8")
|
84
80
|
|
85
81
|
|
86
82
|
class JsonProducerConfig(ProducerConfig):
|
87
|
-
|
88
|
-
|
89
|
-
encoding: str = Field(default="utf-8"
|
83
|
+
"""Configuration for JSON producer"""
|
84
|
+
json_serializer: Optional[str] = None # Custom serializer function
|
85
|
+
encoding: str = Field(default="utf-8")
|
86
|
+
|
87
|
+
@classmethod
|
88
|
+
@validator("compression_type")
|
89
|
+
def validate_compression(cls, v):
|
90
|
+
if v not in ["none", "gzip", "snappy", "lz4", "zstd"]:
|
91
|
+
raise ValueError("Unsupported compression type")
|
92
|
+
return v
|
@@ -1,13 +1,13 @@
|
|
1
1
|
dgkafka/__init__.py,sha256=fnqVZROyHXipdmhqZaa9XUjvQe795JJKFakwTndAiIw,286
|
2
2
|
dgkafka/avro_consumer.py,sha256=Hk1_vexqd5F2g2D0IC2n1HAwXR-cQrbYDsSYr616ASY,2875
|
3
3
|
dgkafka/avro_producer.py,sha256=51p9GeavU3M21LfQZuidEkhIpzA-KGQOXhB0xMfNUus,4247
|
4
|
-
dgkafka/config.py,sha256=
|
4
|
+
dgkafka/config.py,sha256=km3v3FwcCyqx0iV1QUyqeelCiJmdRzU_r9DYgHhIgK8,4272
|
5
5
|
dgkafka/consumer.py,sha256=OSryUsowjpPA4ZbTSs3dwWgIgd2HOAdGeqM-Y1R1XLk,4427
|
6
6
|
dgkafka/errors.py,sha256=PaH46tXameS--hrrUXKhQkZlBHvMSMPmjhVeRkmFvV0,95
|
7
7
|
dgkafka/json_consumer.py,sha256=7Gzn7C9WpyCTPDV6eFDugAx5gC9vdV-HrTh3Nv--zIE,1152
|
8
8
|
dgkafka/producer.py,sha256=4tKIYUs1zlrie5TOxnL0J38BON2HreOLf2rYW1hVrIs,5085
|
9
|
-
dgkafka-1.0.
|
10
|
-
dgkafka-1.0.
|
11
|
-
dgkafka-1.0.
|
12
|
-
dgkafka-1.0.
|
13
|
-
dgkafka-1.0.
|
9
|
+
dgkafka-1.0.0a6.dist-info/licenses/LICENSE,sha256=pAZXnNE2dxxwXFIduGyn1gpvPefJtUYOYZOi3yeGG94,1068
|
10
|
+
dgkafka-1.0.0a6.dist-info/METADATA,sha256=7ZVTz1zURWcA2AFE0XcsyRIxBKRhgFaxdhwsrVYPC0A,6061
|
11
|
+
dgkafka-1.0.0a6.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
12
|
+
dgkafka-1.0.0a6.dist-info/top_level.txt,sha256=GyNrxOh7IPdL0t2SxH8DWxg3fUma-ezQ1Kz4zIr2B7U,8
|
13
|
+
dgkafka-1.0.0a6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|