update
This commit is contained in:
parent
8dcf85dee9
commit
6e8e553592
@ -13,22 +13,13 @@ class ToKafka(BaseOutput):
|
||||
"""
|
||||
|
||||
def __init__(self, conf):
|
||||
self.__topic_name = None
|
||||
self.topic_name = None
|
||||
self.__producer = KafkaProducer(**conf)
|
||||
self.partition = 15
|
||||
|
||||
@property
|
||||
def topic_name(self):
|
||||
return self.__topic_name
|
||||
|
||||
@topic_name.setter
|
||||
def topic_name(self, topic_name):
|
||||
self.__topic_name = topic_name
|
||||
# self.__producer.partitions_for(topic_name)
|
||||
self.__partition = 15
|
||||
|
||||
def send(self, msg):
|
||||
# msg="""{"#type": "user_set", "#ip": "192.168.1.1", "#time": "2021-04-01 17:54:28.084", "properties": {"herostate": [["fffgsa", 2, 3, 4, 5], ["ddd", 4, 5, 6, 8]], "lv": 60, "#user_id": "fvdsvgdsf"}, "#distinct_id": "ABCDEF123456", "#account_id": "TA10001"}"""
|
||||
try:
|
||||
self.__producer.send(self.__topic_name, msg, partition=random.randint(0, self.partition))
|
||||
self.__producer.send(self.topic_name, msg, partition=random.randint(0, self.__partition))
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
Loading…
Reference in New Issue
Block a user