Skip to content

Commit

Permalink
Add comments requested by hound
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoriano committed Sep 23, 2018
1 parent fd424ec commit 3795248
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libbeat/common/kafka/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/Shopify/sarama"
)

// Version is a kafka version
type Version struct {
String string
}
Expand Down Expand Up @@ -89,6 +90,7 @@ func parseKafkaVersion(s string) sarama.KafkaVersion {
return v
}

// Validate that a kafka version is among the possible options
func (v *Version) Validate() error {
if _, ok := kafkaVersions[v.String]; !ok {
return fmt.Errorf("unknown/unsupported kafka vesion '%v'", v.String)
Expand All @@ -97,6 +99,7 @@ func (v *Version) Validate() error {
return nil
}

// Unpack a kafka version
func (v *Version) Unpack(s string) error {
tmp := Version{s}
if err := tmp.Validate(); err != nil {
Expand All @@ -107,6 +110,7 @@ func (v *Version) Unpack(s string) error {
return nil
}

// Get a sarama kafka version
func (v *Version) Get() (sarama.KafkaVersion, bool) {
kv, ok := kafkaVersions[v.String]
return kv, ok
Expand Down

0 comments on commit 3795248

Please sign in to comment.