https://github.com/root-gg/kamux
Kamux is a simple library to consume kafka topics, and execute a handler
https://github.com/root-gg/kamux
Last synced: 3 months ago
JSON representation
Kamux is a simple library to consume kafka topics, and execute a handler
- Host: GitHub
- URL: https://github.com/root-gg/kamux
- Owner: root-gg
- License: mit
- Created: 2018-08-31T08:15:53.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-10-22T16:21:11.000Z (over 2 years ago)
- Last Synced: 2025-06-24T08:02:04.021Z (12 months ago)
- Language: Go
- Size: 47.9 KB
- Stars: 4
- Watchers: 6
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://godoc.org/github.com/root-gg/kamux)
[](https://goreportcard.com/report/github.com/root-gg/kamux)
[](https://opensource.org/licenses/MIT)
Kamux
============
Kamux is a simple library to interact with a Kafka cluster.
It can:
* Connect with a kafka cluster (Only SASL/TLS with user/password)
* Listen to one or multiple topics on a specific consumer group
* Execute the function of your choice (handler)
* Mark offset or not after handling
* Listen to SIGINT and stop processing messages gracefully
* Override sarama cluster consumer configuration before Launch()
A simple example :
~~~golang
func main() {
config := &kamux.Config{
Brokers: []string{"kafka.broker1.net:9093", "kafka.broker2.net:9093"},
User: "myKafkaUser",
Password: "myPassword",
Topics: []string{"myTopic"},
ConsumerGroup: "myConsumerGroup",
Handler: Handler,
MarkOffsets: true,
}
kamux, err := kamux.NewKamux(config)
if err != nil {
log.Fatalf("Fail to init kamux: %s", err)
}
kamux.Launch()
}
func Handler(sm *sarama.ConsumerMessage) ( err error ) {
log.Printf("Received a message on topic : %s (partition: %d | offset: %d)", sm.Topic, sm.Partition, sm.Offset)
return
}
~~~