Skip to content

Commit

Permalink
fixed linter (#1065)
Browse files Browse the repository at this point in the history
  • Loading branch information
clD11 authored Dec 21, 2021
1 parent 48cb24f commit 5759912
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion payment/key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestGenerateSecret(t *testing.T) {
if len(bareSecretKey) != 32 {
t.Error("Secret key does not have correct length", err)
}
if len(k) < 0 {
if len(k) <= 0 {
t.Error("the key should be bigger than nothing")
}
}
Expand Down
1 change: 1 addition & 0 deletions promotion/avro.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const adminAttestationEventSchema = `{
{ "name": "created_at", "type": "string" }
]}`

// AdminAttestationEvent - kafka admin attestation event
type AdminAttestationEvent struct {
WalletID string `json:"wallet_id"`
Service string `json:"service"`
Expand Down
6 changes: 3 additions & 3 deletions promotion/drain.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,13 +726,13 @@ func (service *Service) MintGrant(ctx context.Context, walletID uuid.UUID, total
}

// FetchAdminAttestationWalletID - retrieves walletID from topic
func (s *Service) FetchAdminAttestationWalletID(ctx context.Context) (*uuid.UUID, error) {
message, err := s.kafkaAdminAttestationReader.ReadMessage(ctx)
func (service *Service) FetchAdminAttestationWalletID(ctx context.Context) (*uuid.UUID, error) {
message, err := service.kafkaAdminAttestationReader.ReadMessage(ctx)
if err != nil {
return nil, fmt.Errorf("read message: error reading kafka message %w", err)
}

codec, ok := s.codecs[adminAttestationTopic]
codec, ok := service.codecs[adminAttestationTopic]
if !ok {
return nil, fmt.Errorf("read message: could not find codec %s", adminAttestationTopic)
}
Expand Down
1 change: 1 addition & 0 deletions promotion/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func SetAdminAttestationTopic(newTopic string) {
adminAttestationTopic = newTopic
}

// KafkaReader - reader interface
type KafkaReader interface {
ReadMessage(ctx context.Context) (kafka.Message, error)
}
Expand Down
2 changes: 1 addition & 1 deletion utils/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (c *SimpleHTTPClient) do(

// helpful if you want to read the body as it is
bodyBytes, _ := requestutils.Read(resp.Body)
resp.Body.Close() // must close
_ = resp.Body.Close() // must close
resp.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes))

// fmt.Println(req.URL.Host, req.URL.Path, string(bodyBytes))
Expand Down
13 changes: 8 additions & 5 deletions utils/kafka/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@ import (
"time"

"github.com/linkedin/goavro"
kafka "github.com/segmentio/kafka-go"
"github.com/segmentio/kafka-go"

appctx "github.com/brave-intl/bat-go/utils/context"
errorutils "github.com/brave-intl/bat-go/utils/errors"
"github.com/brave-intl/bat-go/utils/logging"
)

type KafkaRead struct {
// Reader - implements KafkaReader
type Reader struct {
kafkaReader *kafka.Reader
kafkaDialer *kafka.Dialer
}

func NewKafkaReader(ctx context.Context, groupID string, topic string) (*KafkaRead, error) {
// NewKafkaReader - creates a new kafka reader for groupID and topic
func NewKafkaReader(ctx context.Context, groupID string, topic string) (*Reader, error) {
_, logger := logging.SetupLogger(ctx)

dialer, x509Cert, err := TLSDialer()
Expand All @@ -49,13 +51,14 @@ func NewKafkaReader(ctx context.Context, groupID string, topic string) (*KafkaRe
Logger: kafka.LoggerFunc(logger.Printf), // FIXME
})

return &KafkaRead{
return &Reader{
kafkaReader: kafkaReader,
kafkaDialer: dialer,
}, nil
}

func (k *KafkaRead) ReadMessage(ctx context.Context) (kafka.Message, error) {
// ReadMessage - reads kafka messages
func (k *Reader) ReadMessage(ctx context.Context) (kafka.Message, error) {
return k.kafkaReader.ReadMessage(ctx)
}

Expand Down

0 comments on commit 5759912

Please sign in to comment.