Skip to content

Commit

Permalink
Use kafka client v4
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasdinov committed Dec 12, 2022
1 parent 727cd07 commit 2bc4be0
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 65 deletions.
14 changes: 11 additions & 3 deletions cmd/content-rw-elasticsearch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/Financial-Times/content-rw-elasticsearch/v4/pkg/mapper"
"github.com/Financial-Times/content-rw-elasticsearch/v4/pkg/message"
"github.com/Financial-Times/go-logger/v2"
"github.com/Financial-Times/kafka-client-go/v3"
"github.com/Financial-Times/kafka-client-go/v4"
awsconfig "github.com/aws/aws-sdk-go-v2/config"
cli "github.com/jawher/mow.cli"
)
Expand Down Expand Up @@ -66,6 +66,11 @@ func main() {
Desc: "The name of the elasticsearch index",
EnvVar: "ELASTICSEARCH_SAPI_INDEX",
})
kafkaClusterArn := app.String(cli.StringOpt{
Name: "kafka-cluster-arn",
Desc: "Addresses used by the queue consumer to connect to Kafka",
EnvVar: "KAFKA_ARN",
})
kafkaAddress := app.String(cli.StringOpt{
Name: "kafka-address",
Value: "kafka:9092",
Expand Down Expand Up @@ -143,16 +148,19 @@ func main() {
mapperHandler := mapper.NewMapperHandler(concordanceAPIService, *baseAPIUrl, appConfig, log)

consumerConfig := kafka.ConsumerConfig{
ClusterArn: kafkaClusterArn,
BrokersConnectionString: *kafkaAddress,
ConsumerGroup: *kafkaConsumerGroup,
ConnectionRetryInterval: time.Minute,
OffsetFetchInterval: time.Duration(*kafkaTopicOffsetFetchInterval) * time.Minute,
Options: kafka.DefaultConsumerOptions(),
}
topics := []*kafka.Topic{
kafka.NewTopic(*kafkaTopic, kafka.WithLagTolerance(int64(*kafkaLagTolerance))),
}
messageConsumer := kafka.NewConsumer(consumerConfig, topics, log)
messageConsumer, err := kafka.NewConsumer(consumerConfig, topics, log)
if err != nil {
log.WithError(err).Fatal("Failed to initialize Kafka consumer")
}

handler := message.NewMessageHandler(
esService,
Expand Down
29 changes: 15 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/Financial-Times/go-fthealth v0.0.0-20180807113633-3d8eb430d5b5
github.com/Financial-Times/go-logger/v2 v2.0.1
github.com/Financial-Times/kafka-client-go/v3 v3.0.5
github.com/Financial-Times/kafka-client-go/v4 v4.1.0-dev
github.com/Financial-Times/service-status-go v0.0.0-20160323111542-3f5199736a3d
github.com/Financial-Times/transactionid-utils-go v0.2.0
github.com/aws/aws-sdk-go-v2 v1.17.1
Expand All @@ -15,44 +15,45 @@ require (
github.com/olivere/elastic/v7 v7.0.29
github.com/pborman/uuid v0.0.0-20170612153648-e790cca94e6c
github.com/spf13/viper v1.9.0
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.0
)

require (
github.com/Shopify/sarama v1.33.0 // indirect
github.com/Shopify/sarama v1.37.2 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.12.23 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.19 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.25 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.19 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.26 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.19 // indirect
github.com/aws/aws-sdk-go-v2/service/kafka v1.18.0 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.11.25 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.8 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.17.1 // indirect
github.com/aws/smithy-go v1.13.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/eapache/go-resiliency v1.2.0 // indirect
github.com/eapache/go-resiliency v1.3.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.0.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.0.0 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.2 // indirect
github.com/jcmturner/gofork v1.7.6 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.3 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.15.0 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
Expand All @@ -61,13 +62,13 @@ require (
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.1.1 // indirect
github.com/stretchr/objx v0.4.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
golang.org/x/net v0.0.0-20220927171203-f486391704dc // indirect
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/ini.v1 v1.63.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

0 comments on commit 2bc4be0

Please sign in to comment.