Describe the bug
There was an error in the example of using python function that causes the following exception to be thrown:
2019-11-11 09:48:43 +0000] [ERROR] log.py: Traceback (most recent call last):
[2019-11-11 09:48:43 +0000] [ERROR] log.py: File "/pulsar/instances/python-instance/python_instance_main.py", line 211, in <module>
[2019-11-11 09:48:43 +0000] [ERROR] log.py: main()
[2019-11-11 09:48:43 +0000] [ERROR] log.py: File "/pulsar/instances/python-[instance/python_instance_main.py", line 192, in main
[2019-11-11 09:48:43 +0000] [ERROR] log.py: pyinstance.run()
[2019-11-11 09:48:43 +0000] [ERROR] log.py: File "/pulsar/instances/python-instance/python_instance.py", line 186, in run
[2019-11-11 09:48:43 +0000] [ERROR] log.py: self.input_serdes[topic] = serde_kclass()
[2019-11-11 09:48:43 +0000] [ERROR] log.py: TypeError
[2019-11-11 09:48:43 +0000] [ERROR] log.py: :
[2019-11-11 09:48:43 +0000] [ERROR] log.py: __init__() takes exactly 2 arguments (1 given)
Parameters should not appear in the initialization function of class TweetSerDe, messages should come from the topic and should not be assigned during initialization. the document example is wrong, and the correct example should be:
class Tweet(object):
def __init__(self, username, tweet_content):
self.username = username
self.tweet_content = tweet_content
from pulsar import SerDe
class TweetSerDe(SerDe):
def __init__(self):
pass
def serialize(self, input):
return bytes("{0}|{1}".format(input.username, input.tweet_content))
def deserialize(self, input_bytes):
tweet_components = str(input_bytes).split('|')
return Tweet(tweet_components[0], tweet_componentsp[1])
Reference: https://github.com/apache/pulsar/blob/master/pulsar-functions/python-examples/custom_object_function.py
Expected behavior
Fix document
Additional context
Use the correct example on the document
Describe the bug
There was an error in the example of using python function that causes the following exception to be thrown:
Parameters should not appear in the initialization function of class TweetSerDe, messages should come from the topic and should not be assigned during initialization. the document example is wrong, and the correct example should be:
Reference: https://github.com/apache/pulsar/blob/master/pulsar-functions/python-examples/custom_object_function.py
Expected behavior
Fix document
Additional context
Use the correct example on the document