kafka: CheckPartitions() method for health checks
This commit is contained in:
parent
2a021b453d
commit
e9d0f7419a
@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/abh/certman"
|
"github.com/abh/certman"
|
||||||
"github.com/segmentio/kafka-go"
|
"github.com/segmentio/kafka-go"
|
||||||
|
"go.ntppool.org/common/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -203,3 +204,17 @@ func (k *Kafka) NewWriter(topic string) (*kafka.Writer, error) {
|
|||||||
|
|
||||||
return w, nil
|
return w, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (k *Kafka) CheckPartitions() error {
|
||||||
|
partitions, err := k.conn.ReadPartitions()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// should this result in an error?
|
||||||
|
if len(partitions) == 0 {
|
||||||
|
log := logger.Setup()
|
||||||
|
log.Info("kafka connection has no partitions")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user