dgkafka 1.0.0a9__tar.gz → 1.0.0a11__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dgkafka
3
- Version: 1.0.0a9
3
+ Version: 1.0.0a11
4
4
  Summary: Kafka clients
5
5
  Home-page: https://gitlab.com/gng-group/dgkafka.git
6
6
  Author: Malanris
@@ -84,16 +84,27 @@ class AvroKafkaProducer(KafkaProducer):
84
84
  for k, v in headers.items()]
85
85
 
86
86
  try:
87
- producer.produce(
88
- topic=topic,
89
- value=value,
90
- value_schema=value_schema,
91
- key=key,
92
- key_schema=key_schema,
93
- partition=partition,
94
- on_delivery=self.delivery_report,
95
- headers=headers_list
96
- )
87
+ if not partition:
88
+ producer.produce(
89
+ topic=topic,
90
+ value=value,
91
+ value_schema=value_schema,
92
+ key=key,
93
+ key_schema=key_schema,
94
+ on_delivery=self.delivery_report,
95
+ headers=headers_list
96
+ )
97
+ else:
98
+ producer.produce(
99
+ topic=topic,
100
+ value=value,
101
+ value_schema=value_schema,
102
+ key=key,
103
+ key_schema=key_schema,
104
+ partition=partition,
105
+ on_delivery=self.delivery_report,
106
+ headers=headers_list
107
+ )
97
108
 
98
109
  if flush:
99
110
  producer.flush()
@@ -27,7 +27,7 @@ class KafkaConfig(BaseModel):
27
27
 
28
28
  def get(self) -> Dict[str, Any]:
29
29
  """Get config in format suitable for confluent_kafka"""
30
- return self.model_dump(by_alias=True, exclude_none=True)
30
+ return self.model_dump(by_alias=True)
31
31
 
32
32
  @classmethod
33
33
  def set(cls, config_dict: Dict[str, Any]) -> "KafkaConfig":
@@ -119,18 +119,25 @@ class KafkaProducer:
119
119
 
120
120
  # Produce message
121
121
  try:
122
- producer.produce(
123
- topic=topic,
124
- value=value,
125
- key=key_bytes,
126
- partition=partition,
127
- on_delivery=self.delivery_report,
128
- headers=headers_list
129
- )
130
-
122
+ if not partition:
123
+ producer.produce(
124
+ topic=topic,
125
+ value=value,
126
+ key=key_bytes,
127
+ on_delivery=self.delivery_report,
128
+ headers=headers_list
129
+ )
130
+ else:
131
+ producer.produce(
132
+ topic=topic,
133
+ value=value,
134
+ key=key_bytes,
135
+ partition=partition,
136
+ on_delivery=self.delivery_report,
137
+ headers=headers_list
138
+ )
131
139
  if flush:
132
140
  producer.flush()
133
-
134
141
  except Exception as ex:
135
142
  self.logger.error(f"[x] Failed to produce message: {ex}")
136
143
  raise
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dgkafka
3
- Version: 1.0.0a9
3
+ Version: 1.0.0a11
4
4
  Summary: Kafka clients
5
5
  Home-page: https://gitlab.com/gng-group/dgkafka.git
6
6
  Author: Malanris
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dgkafka"
7
- version = "1.0.0a9"
7
+ version = "1.0.0a11"
8
8
  authors = [
9
9
  {name = "Roman Rasputin", email = "admin@roro.su"},
10
10
  ]
File without changes
File without changes
File without changes
File without changes
File without changes