DarkbordermanTemplate / kafka-consumer

A simple kafka streaming template using confluent-kafka.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

kafka-consumer

A simple Kafka consumer example template using confluent-kafka.

Integration Build

Development

Prerequisitive

Name Version
Python 3.7
pipenv(Python module) 2018.11.26 or up

Environment setup

  1. Initialize environment variable
cp sample.env .env
  1. Initialize Python environment
make init
  1. Enter the environment and start developing
pipenv shell
  1. Start kafka-consumer service
cd kafka/
python3 kafka/app.py

The service will start at 127.0.0.1:9092

Formatting

This project uses black and isort for formatting

make reformat

Linting

This project uses pylint and flake8 for linting

make lint

Testing

This project uses pytest and its extension(pytest-cov) for testing

Deployment

Prerequisitive

Name Version
Docker 19.03.6
docker-compose 1.17.1

Building image

docker-compose build

This will build the image with tag kafka-consumer:latest

Integration testing(with a single-node kafka)

  1. Start containers
docker-compose up -d
  1. Enter kafka and create example messages
docker exec -it kafka bash
(In kafka container)kafka-producer-perf-test\
 --topic example\
 --throughput -1\
 --num-records 1\
 --record-size 1\
 --producer-props bootstrap.servers=kafka:9092

Contribution

About

A simple kafka streaming template using confluent-kafka.

License:BSD 2-Clause "Simplified" License


Languages

Language:Python 78.9%Language:Makefile 15.5%Language:Dockerfile 4.7%Language:Shell 0.9%