Skip to main content

An XO core utils project.

Project description

# xoc-utils-python

An XO core project in python that provides utils functionalities, including data processing and Kafka client.


## Kafka

### Producer

producer = KProducer('kafka_server_origin', 'service_name')
message = json.dumps({
'hello': 'world'
producer.produce('topic_name', message)
Example [here](examples/

### Consumer

Consumer without retry
consumer = KConsumer('kafka_server_origin', 'group_id', 'service_name', poll_timeout=1, retries=0)

# Add handler for a topic
def printMsg(msg):
print('consuming message: ', msg)
raise Exception('I am Exception.')
consumer.add_handler('topic_name', printMsg)
Example [here](examples/
If you want to use retry feature, you can just set retries to the times you want it to retry, like 3.
Example [here](examples/

## Others

### Singleton
This provide you a way to create a singleton instance.

from xoc_utils import Singleton

class YourClass(metaclass=Singleton):

## Development
You get start from [here](

To debug your package, you don't have to release it, you can just run
python install
then it will be installed on your machine.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for xoc-utils-python, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size xoc_utils_python-0.0.2-py3.6.egg (9.7 kB) File type Egg Python version 3.6 Upload date Hashes View
Filename, size xoc-utils-python-0.0.2.tar.gz (5.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page