Help us shape the future of Go! Take the 2026 Go Developer Survey

sarama

module
v0.0.0-...-cb40b81 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2017 License: MIT

README

sarama

This is a sample project to use sarama, sarama is golang client library for Apache kafka. This repositry contains simple producer and consumer. To use this you need to prepare kafka (or you can run it by docker image).

Install

To get sarama,

$ go get github.com/Shopify/sarama

Build

To build producer & consumer, run below. Binary is generated in each directory,

$ make build

Usage

Ensure kafka is running on where you expect.

To execute consumer, run below. Consumer tries to fetch topic until received os.Interrupt signal.

$ ./consumer/consumer

To execute async-producer, run below. Producer tries to publish messages until received os.Interrupt signal.

$ ./async-producer/async-producer

Kafka on Docker

You can run kafka on docker. And you can also run producer & consumer on docker.

To build docker image of kafka,

$ make docker-build

To run kafka container,

$ ./docker-run.sh

To execute consumer,

$ docker exec -it kafka /work/consumer/consumer

To execute async-producer,

$ docker exec -it kafka /work/async-producer/async-producer

To execute http-log-producer,

$ docker exec -it kafka /work/http-log-producer/http-log-producer

And access it (e.g., docker is on boot2docker),

$ curl $(boot2docker ip):8080

Author

Taichi Nakashima

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL