README.md.tpl 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Sarama Cluster
  2. [![GoDoc](https://godoc.org/github.com/bsm/sarama-cluster?status.svg)](https://godoc.org/github.com/bsm/sarama-cluster)
  3. [![Build Status](https://travis-ci.org/bsm/sarama-cluster.svg?branch=master)](https://travis-ci.org/bsm/sarama-cluster)
  4. [![Go Report Card](https://goreportcard.com/badge/github.com/bsm/sarama-cluster)](https://goreportcard.com/report/github.com/bsm/sarama-cluster)
  5. [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
  6. Cluster extensions for [Sarama](https://github.com/Shopify/sarama), the Go client library for Apache Kafka 0.9 (and later).
  7. ## Documentation
  8. Documentation and example are available via godoc at http://godoc.org/github.com/bsm/sarama-cluster
  9. ## Examples
  10. Consumers have two modes of operation. In the default multiplexed mode messages (and errors) of multiple
  11. topics and partitions are all passed to the single channel:
  12. ```go
  13. package main
  14. import (
  15. "fmt"
  16. "log"
  17. "os"
  18. "os/signal"
  19. cluster "github.com/bsm/sarama-cluster"
  20. )
  21. func main() {{ "ExampleConsumer" | code }}
  22. ```
  23. Users who require access to individual partitions can use the partitioned mode which exposes access to partition-level
  24. consumers:
  25. ```go
  26. package main
  27. import (
  28. "fmt"
  29. "log"
  30. "os"
  31. "os/signal"
  32. cluster "github.com/bsm/sarama-cluster"
  33. )
  34. func main() {{ "ExampleConsumer_Partitions" | code }}
  35. ```
  36. ## Running tests
  37. You need to install Ginkgo & Gomega to run tests. Please see
  38. http://onsi.github.io/ginkgo for more details.
  39. To run tests, call:
  40. $ make test
  41. ## Troubleshooting
  42. ### Consumer not receiving any messages?
  43. By default, sarama's `Config.Consumer.Offsets.Initial` is set to `sarama.OffsetNewest`. This means that in the event that a brand new consumer is created, and it has never committed any offsets to kafka, it will only receive messages starting from the message after the current one that was written.
  44. If you wish to receive all messages (from the start of all messages in the topic) in the event that a consumer does not have any offsets committed to kafka, you need to set `Config.Consumer.Offsets.Initial` to `sarama.OffsetOldest`.