Skip to content

Commit

Permalink
refactor pinotClient to pass in pinotConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenxia committed Jun 22, 2023
1 parent d59ad98 commit 4f403b2
Show file tree
Hide file tree
Showing 11 changed files with 481 additions and 534 deletions.
72 changes: 4 additions & 68 deletions .gen/go/shared/shared.go

Large diffs are not rendered by default.

299 changes: 149 additions & 150 deletions .gen/proto/history/v1/service.pb.yarpc.go

Large diffs are not rendered by default.

299 changes: 149 additions & 150 deletions .gen/proto/matching/v1/service.pb.yarpc.go

Large diffs are not rendered by default.

299 changes: 149 additions & 150 deletions .gen/proto/shared/v1/history.pb.yarpc.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cmd/server/cadence/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (s *server) startService() common.Daemon {
if err != nil || pinotRawClient == nil {
log.Fatalf("Creating Pinot visibility client failed: %v", err)
}
pinotClient := pnt.NewPinotClient(pinotRawClient, params.Logger, params.PinotConfig.Table)
pinotClient := pnt.NewPinotClient(pinotRawClient, params.Logger, params.PinotConfig)
params.PinotClient = pinotClient
} else {
params.ESConfig = advancedVisStore.ElasticSearch
Expand Down
7 changes: 4 additions & 3 deletions common/config/pinot.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ package config
// PinotVisibilityConfig for connecting to Pinot
type (
PinotVisibilityConfig struct {
Cluster string `yaml:"cluster"` //nolint:govet
Broker string `yaml:"broker"` //nolint:govet
Table string `yaml:"table"` //nolint:govet
Cluster string `yaml:"cluster"` //nolint:govet
Broker string `yaml:"broker"` //nolint:govet
Table string `yaml:"table"` //nolint:govet
ServiceName string `yaml:"serviceName"` //nolint:govet
}
)
18 changes: 11 additions & 7 deletions common/pinot/pinotClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"fmt"
"reflect"

"github.com/uber/cadence/common/config"

"github.com/startreedata/pinot-client-go/pinot"

"github.com/uber/cadence/common/log"
Expand All @@ -35,16 +37,18 @@ import (
)

type PinotClient struct {
client *pinot.Connection
logger log.Logger
tableName string
client *pinot.Connection
logger log.Logger
tableName string
serviceName string
}

func NewPinotClient(client *pinot.Connection, logger log.Logger, tableName string) GenericClient {
func NewPinotClient(client *pinot.Connection, logger log.Logger, pinotConfig *config.PinotVisibilityConfig) GenericClient {
return &PinotClient{
client: client,
logger: logger,
tableName: tableName,
client: client,
logger: logger,
tableName: pinotConfig.Table,
serviceName: pinotConfig.ServiceName,
}
}

Expand Down
9 changes: 8 additions & 1 deletion host/pinot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (

"testing"

"github.com/uber/cadence/common/config"
"github.com/uber/cadence/common/log"
"github.com/uber/cadence/common/log/loggerimpl"
"github.com/uber/cadence/common/log/tag"
Expand Down Expand Up @@ -99,8 +100,14 @@ func (s *PinotIntegrationSuite) SetupSuite() {
s.Require().NoError(err)
s.logger = loggerimpl.NewLogger(zapLogger)
tableName := "cadence_visibility_pinot" //cadence_visibility_pinot_integration_test
pinotConfig := &config.PinotVisibilityConfig{
Cluster: "",
Broker: "",
Table: tableName,
ServiceName: "",
}
url := "localhost:8099"
s.pinotClient = pinotutils.CreatePinotClient(s.Suite, url, tableName, s.logger)
s.pinotClient = pinotutils.CreatePinotClient(s.Suite, url, pinotConfig, s.logger)
}

func (s *PinotIntegrationSuite) SetupTest() {
Expand Down
6 changes: 4 additions & 2 deletions host/pinotutils/pinotClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"github.com/startreedata/pinot-client-go/pinot"
"github.com/stretchr/testify/suite"

"github.com/uber/cadence/common/config"

"github.com/uber/cadence/common/log"
pnt "github.com/uber/cadence/common/pinot"
)
Expand All @@ -32,9 +34,9 @@ import (
client pnt.GenericClient
}*/

func CreatePinotClient(s suite.Suite, url string, tableName string, logger log.Logger) pnt.GenericClient {
func CreatePinotClient(s suite.Suite, url string, pinotConfig *config.PinotVisibilityConfig, logger log.Logger) pnt.GenericClient {
pinotRawClient, err := pinot.NewFromBrokerList([]string{url})
s.Require().NoError(err)
pinotClient := pnt.NewPinotClient(pinotRawClient, logger, tableName)
pinotClient := pnt.NewPinotClient(pinotRawClient, logger, pinotConfig)
return pinotClient
}
2 changes: 1 addition & 1 deletion host/testcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func NewPinotTestCluster(options *TestClusterConfig, logger log.Logger, params p
if err != nil || pinotRawClient == nil {
return nil, err
}
pinotClient = pnt.NewPinotClient(pinotRawClient, logger, options.PinotConfig.Table)
pinotClient = pnt.NewPinotClient(pinotRawClient, logger, options.PinotConfig)
}

scope := tally.NewTestScope("integration-test", nil)
Expand Down
2 changes: 1 addition & 1 deletion idls
Submodule idls updated from b6f203 to 88be14

0 comments on commit 4f403b2

Please sign in to comment.