Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 924 Bytes

README.md

File metadata and controls

40 lines (28 loc) · 924 Bytes

metamorphosis

metamorphosis is a Go client for easily interacting with Kafka. It works best when used to handle a Kafka setup that's clustered with Zookeeper and whose messages are encoded with Avro.

Usage

import "github.com/FoxComm/metamorphosis"

Construct a new consumer by creating a Consumer that connects to Zookeeper and the Avro schema registry and provide offset reset strategy value ("largest" or "smallest").

For example:

zookeeper := "localhost:2181"
schemaRepo := "http://localhost:8081"
resetOffsetStrategy := "smallest" // or "largest"

consumer, err := metamorphosis.NewConsumer(zookeeper, schemaRepo, resetOffsetStrategy)

To handle messages, define a handler and run against a topic:

handler := func(message AvroMessage) error {
  bytes := message.Bytes()
  fmt.Println(string(bytes))
  return nil
}

consumer.RunTopic("my_topic", handler)

License

MIT