Python MAPR Kafka REST wrapper
Project description
pymapr-kafkarest
Introduction
The aim of the project is to create a super-simple wrapper for MAPR Kafka REST proxy. We're trying to allow users to interact with MAPR Kafka in an elementary way and writing less code as possible.
The original documentation of the REST calls can be found here.
Installation
Soon available via pip:
pip install pymapr-kafkarest
Runtime configurations
KAFKAREST_LOG_LEVEL
: allows to set the log level... default toDEBUG
TBC
Usage
Import the lib
from pymapr_kafkarest import MaprKlient
Define basic attributes
base_url = 'http://my-endopoint:8082'
user_group = 'foo'
topics = ['/streams/foo:bar']
and instantiate the client
mk = MaprKlient(base_url, user_group, topics=topics)
Connect, subscribe and consume messages as follows:
base_url = 'http://my-endopoint:8082'
if __name__ == '__main__':
mk = MaprKlient(base_url, user_group, headers=headers, topics=topics)
mk.connect(clear=True)
mk.subscribe()
messages = mk.consume()
print(messages)
Connect and produce messages:
from pymapr_kafkarest import MaprKlient
from pymapr_kafkarest.kafkarest import MaprKProducer
base_url = 'https://localhost:8082'
headers = {}
user_group = 'me'
if __name__ == '__main__':
# producing
mp = MaprKProducer(base_url, user_group, headers=headers)
msgs = [dict(key='0099', value=dict(color='red', shape='square'))]
mp.produce(messages=msgs, topic='/streams/foo')
TODO
- a lot of methods are not yet implemented
- full read the docs
- chain
connect
,subscribe
andconsume
in a new method namedstream
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pymapr-kafkarest-0.0.2.tar.gz
(5.4 kB
view hashes)
Built Distribution
Close
Hashes for pymapr_kafkarest-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 142d6b63cf6fdf05b9048e8a748593cdc47eade60c05a9f83c887952caf2d624 |
|
MD5 | 343755eb37e4f263ddfb672b1e006cfc |
|
BLAKE2b-256 | c7954f2b302ba06e9426c57e6b3d8ee726d567e5b4256a3320d0c7c960d6069f |