projects
/
osm
/
common.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
database get filtering enhancement for arrays
[osm/common.git]
/
osm_common
/
msgkafka.py
diff --git
a/osm_common/msgkafka.py
b/osm_common/msgkafka.py
index
382bdef
..
2d82f97
100644
(file)
--- a/
osm_common/msgkafka.py
+++ b/
osm_common/msgkafka.py
@@
-41,17
+41,22
@@
class MsgKafka(MsgBase):
raise MsgException(str(e))
def write(self, topic, key, msg):
raise MsgException(str(e))
def write(self, topic, key, msg):
+ """
+ Write a message at kafka bus
+ :param topic: message topic, must be string
+ :param key: message key, must be string
+ :param msg: message content, can be string or dictionary
+ :return: None or raises MsgException on failing
+ """
try:
try:
- self.loop.run_until_complete(self.aiowrite(topic=topic, key=key,
- msg=yaml.safe_dump(msg, default_flow_style=True),
- loop=self.loop))
+ self.loop.run_until_complete(self.aiowrite(topic=topic, key=key, msg=msg))
except Exception as e:
raise MsgException("Error writing {} topic: {}".format(topic, str(e)))
def read(self, topic):
"""
except Exception as e:
raise MsgException("Error writing {} topic: {}".format(topic, str(e)))
def read(self, topic):
"""
- Read from one or several topics.
it is non blocking returning None if nothing is available
+ Read from one or several topics.
:param topic: can be str: single topic; or str list: several topics
:return: topic, key, message; or None
"""
:param topic: can be str: single topic; or str list: several topics
:return: topic, key, message; or None
"""