项目作者: apanagiotou

项目描述 :
An S3 Kafka Connector
高级语言: Go
项目地址: git://github.com/apanagiotou/go-kafka-to-s3.git
创建时间: 2018-08-05T17:40:53Z
项目社区:https://github.com/apanagiotou/go-kafka-to-s3

开源协议:

下载


go-kafka-to-s3

go-kafka-to-s3 is a kafka consumer written in Go. Reads messages from a topic, gathers them in batches (files) of a pre-defined size and stores them in S3. It’s useful if you want to have your data in a persistent storage for later process.

Getting Started

These instructions will get you a copy of the project up and running.

Installing

A step by step series of examples that tell you how to get a development env running

First build the docker image

  1. git clone https://github.com/apanagiotou/go-kafka-to-s3
  2. cd go-kafka-to-s3
  3. docker build -t go-kafka-to-s3 .

The run the docker container. You need (at least) one kafka broker, an AWS key and secret and, an S3 bucket

  1. docker run --rm --name go-kafka-to-s3 -it \
  2. -e BOOTSTRAP_SERVERS=ip:port \
  3. -e KAFKA_TOPIC=topic \
  4. -e S3_BUCKET=your-bucket-name \
  5. -e S3_REGION=eu-west-1 \
  6. -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
  7. -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
  8. go-kafka-to-s3

There are a couple of configuration variables that you can also change. Here are the default values for them:

  • KAFKA_CONSUMER_GROUP=go-kafka-to-s3
  • S3_BUCKET_SUBPATH=your-bucket-folder
  • FILE_SIZE_THRESHOLD_MB=10

Example:

  1. docker run --rm --name go-kafka-to-s3 -it \
  2. -e BOOTSTRAP_SERVERS=10.1.0.1:9092 \
  3. -e KAFKA_TOPIC=bookings \
  4. -e S3_BUCKET=apanagiotou-bookings \
  5. -e S3_BUCKET_SUBPATH=test-folder \
  6. -e S3_REGION=eu-west-1 \
  7. -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
  8. -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
  9. go-kafka-to-s3

Running the tests

  1. go test ./...

Authors