Skip to content

Commit 4f0f69e

Browse files
committed
Add __len__ to ConfigResource and overwrite option to .set_config
1 parent c87cc7f commit 4f0f69e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

confluent_kafka/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,14 @@ def __lt__(self, other):
206206
def __eq__(self, other):
207207
return self.restype == other.restype and self.name == other.name
208208

209-
def set_config(self, name, value):
209+
def __len__(self):
210+
"""
211+
:rtype int:
212+
:returns: number of configuration entries/operations
213+
"""
214+
return len(self.add_config_dict) + len(self.set_config_dict) + len(self.del_config_dict)
215+
216+
def set_config(self, name, value, overwrite=True):
210217
"""
211218
Set/Overwrite configuration entry
212219
@@ -217,7 +224,11 @@ def set_config(self, name, value):
217224
218225
:param name str: Configuration property name
219226
:param value str: Configuration value
227+
:param overwrite bool: If True overwrite entry if already exists (default).
228+
If False do nothing if entry already exists.
220229
"""
230+
if not overwrite and name in self.set_config_dict:
231+
return
221232
self.set_config_dict[name] = value
222233

223234
def add_config(self, name, value):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy