Skip to content

Commit

Permalink
Use new resource struct for frontend (#2851)
Browse files Browse the repository at this point in the history
  • Loading branch information
yycptt authored Nov 26, 2019
1 parent 5e0a62b commit 41f1acc
Show file tree
Hide file tree
Showing 16 changed files with 822 additions and 1,229 deletions.
2 changes: 1 addition & 1 deletion cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (s *server) startService() common.Daemon {

switch s.name {
case frontendService:
daemon = frontend.NewService(&params)
daemon, err = frontend.NewService(&params)
case historyService:
daemon = history.NewService(&params)
case matchingService:
Expand Down
22 changes: 22 additions & 0 deletions common/resource/resourceImpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,27 @@ func New(
common.IsWhitelistServiceTransientError,
)

historyArchiverBootstrapContainer := &archiver.HistoryBootstrapContainer{
HistoryV2Manager: persistenceBean.GetHistoryManager(),
Logger: logger,
MetricsClient: params.MetricsClient,
ClusterMetadata: params.ClusterMetadata,
DomainCache: domainCache,
}
visibilityArchiverBootstrapContainer := &archiver.VisibilityBootstrapContainer{
Logger: logger,
MetricsClient: params.MetricsClient,
ClusterMetadata: params.ClusterMetadata,
DomainCache: domainCache,
}
if err := params.ArchiverProvider.RegisterBootstrapContainer(
serviceName,
historyArchiverBootstrapContainer,
visibilityArchiverBootstrapContainer,
); err != nil {
return nil, err
}

impl = &Impl{
status: common.DaemonStatusInitialized,

Expand Down Expand Up @@ -350,6 +371,7 @@ func (h *Impl) Stop() {
}
h.runtimeMetricsReporter.Stop()
h.persistenceBean.Close()
h.visibilityMgr.Close()
}

// GetServiceName return service name
Expand Down
37 changes: 23 additions & 14 deletions common/resource/resourceTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"go.uber.org/cadence/.gen/go/cadence/workflowserviceclient"
publicservicetest "go.uber.org/cadence/.gen/go/cadence/workflowservicetest"

"github.com/uber/cadence/.gen/go/admin/adminservicetest"
"github.com/uber/cadence/.gen/go/cadence/workflowservicetest"
"github.com/uber/cadence/.gen/go/history/historyservicetest"
"github.com/uber/cadence/.gen/go/matching/matchingservicetest"
Expand Down Expand Up @@ -78,11 +79,13 @@ type (

// internal services clients

SDKClient *publicservicetest.MockClient
FrontendClient *workflowservicetest.MockClient
MatchingClient *matchingservicetest.MockClient
HistoryClient *historyservicetest.MockClient
ClientBean *client.MockBean
SDKClient *publicservicetest.MockClient
FrontendClient *workflowservicetest.MockClient
MatchingClient *matchingservicetest.MockClient
HistoryClient *historyservicetest.MockClient
RemoteAdminClient *adminservicetest.MockClient
RemoteFrontendClient *workflowservicetest.MockClient
ClientBean *client.MockBean

// persistence clients

Expand Down Expand Up @@ -124,10 +127,14 @@ func NewTest(
frontendClient := workflowservicetest.NewMockClient(controller)
matchingClient := matchingservicetest.NewMockClient(controller)
historyClient := historyservicetest.NewMockClient(controller)
remoteFrontendClient := workflowservicetest.NewMockClient(controller)
remoteAdminClient := adminservicetest.NewMockClient(controller)
clientBean := client.NewMockBean(controller)
clientBean.EXPECT().GetFrontendClient().Return(frontendClient).AnyTimes()
clientBean.EXPECT().GetMatchingClient(gomock.Any()).Return(matchingClient, nil).AnyTimes()
clientBean.EXPECT().GetHistoryClient().Return(historyClient).AnyTimes()
clientBean.EXPECT().GetRemoteAdminClient(gomock.Any()).Return(remoteAdminClient).AnyTimes()
clientBean.EXPECT().GetRemoteFrontendClient(gomock.Any()).Return(remoteFrontendClient).AnyTimes()

metadataMgr := &mocks.MetadataManager{}
taskMgr := &mocks.TaskManager{}
Expand Down Expand Up @@ -166,11 +173,13 @@ func NewTest(

// internal services clients

SDKClient: publicservicetest.NewMockClient(controller),
FrontendClient: frontendClient,
MatchingClient: matchingClient,
HistoryClient: historyClient,
ClientBean: clientBean,
SDKClient: publicservicetest.NewMockClient(controller),
FrontendClient: frontendClient,
MatchingClient: matchingClient,
HistoryClient: historyClient,
RemoteAdminClient: remoteAdminClient,
RemoteFrontendClient: remoteFrontendClient,
ClientBean: clientBean,

// persistence clients

Expand Down Expand Up @@ -314,28 +323,28 @@ func (s *Test) GetMatchingClient() matching.Client {

// GetHistoryRawClient for testing
func (s *Test) GetHistoryRawClient() history.Client {
return s.ClientBean.GetHistoryClient()
return s.HistoryClient
}

// GetHistoryClient for testing
func (s *Test) GetHistoryClient() history.Client {
return s.ClientBean.GetHistoryClient()
return s.HistoryClient
}

// GetRemoteAdminClient for testing
func (s *Test) GetRemoteAdminClient(
cluster string,
) admin.Client {

return s.ClientBean.GetRemoteAdminClient(cluster)
return s.RemoteAdminClient
}

// GetRemoteFrontendClient for testing
func (s *Test) GetRemoteFrontendClient(
cluster string,
) frontend.Client {

return s.ClientBean.GetRemoteFrontendClient(cluster)
return s.RemoteFrontendClient
}

// GetClientBean for testing
Expand Down
3 changes: 2 additions & 1 deletion host/dynamicconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ import (
"time"

"github.com/uber/cadence/common"

"github.com/uber/cadence/common/service/dynamicconfig"
)

var (
// Override value for integer keys for dynamic config
intKeys = map[dynamicconfig.Key]int{
dynamicconfig.FrontendRPS: 3000,
dynamicconfig.FrontendVisibilityListMaxQPS: 100,
dynamicconfig.FrontendESIndexMaxResultWindow: defaultTestValueOfESIndexMaxResultWindow,
dynamicconfig.MatchingNumTasklistWritePartitions: 3,
dynamicconfig.MatchingNumTasklistReadPartitions: 3,
}
Expand Down
Loading

0 comments on commit 41f1acc

Please sign in to comment.