Skip to content

Commit

Permalink
make register domain aware of active cluster name (cadence-workflow#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
wxing1292 authored Feb 23, 2018
1 parent 2740e6b commit ad78f5f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 6 deletions.
5 changes: 2 additions & 3 deletions .gen/go/shared/idl.go

Large diffs are not rendered by default.

40 changes: 38 additions & 2 deletions .gen/go/shared/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion host/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,15 @@ func (s *integrationSuite) TestIntegrationRegisterGetDomain_NoDefault() {
email := "some random email"
retention := int32(7)
emitMetric := true
activeClusterName := ""
clusters := []*workflow.ClusterReplicationConfiguration{}
for clusterName := range s.ClusterMetadata.GetAllClusterNames() {
clusters = append(clusters, &workflow.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(clusterName),
})
if clusterName != s.ClusterMetadata.GetCurrentClusterName() {
activeClusterName = clusterName
}
}

err := s.engine.RegisterDomain(createContext(), &workflow.RegisterDomainRequest{
Expand All @@ -214,6 +218,7 @@ func (s *integrationSuite) TestIntegrationRegisterGetDomain_NoDefault() {
WorkflowExecutionRetentionPeriodInDays: common.Int32Ptr(retention),
EmitMetric: common.BoolPtr(emitMetric),
Clusters: clusters,
ActiveClusterName: common.StringPtr(activeClusterName),
})
s.Nil(err)

Expand All @@ -227,7 +232,7 @@ func (s *integrationSuite) TestIntegrationRegisterGetDomain_NoDefault() {
s.Equal(email, resp.DomainInfo.GetOwnerEmail())
s.Equal(retention, resp.Configuration.GetWorkflowExecutionRetentionPeriodInDays())
s.Equal(emitMetric, resp.Configuration.GetEmitMetric())
s.Equal(s.ClusterMetadata.GetCurrentClusterName(), resp.ReplicationConfiguration.GetActiveClusterName())
s.Equal(activeClusterName, resp.ReplicationConfiguration.GetActiveClusterName())
s.Equal(clusters, resp.ReplicationConfiguration.Clusters)
}

Expand Down
1 change: 1 addition & 0 deletions idl/github.com/uber/cadence/shared.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ struct RegisterDomainRequest {
40: optional i32 workflowExecutionRetentionPeriodInDays
50: optional bool emitMetric
60: optional list<ClusterReplicationConfiguration> clusters
70: optional string activeClusterName
}

struct DescribeDomainRequest {
Expand Down
6 changes: 6 additions & 0 deletions service/frontend/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ func (wh *WorkflowHandler) RegisterDomain(ctx context.Context, registerRequest *
// input validation on cluster names
clusterMetadata := wh.GetClusterMetadata()
activeClusterName := clusterMetadata.GetCurrentClusterName()
if registerRequest.ActiveClusterName != nil {
activeClusterName = registerRequest.GetActiveClusterName()
if err := wh.validateClusterName(activeClusterName); err != nil {
return wh.error(err, scope)
}
}
clusters := []*persistence.ClusterReplicationConfig{}
for _, cluster := range registerRequest.Clusters {
clusterName := cluster.GetClusterName()
Expand Down

0 comments on commit ad78f5f

Please sign in to comment.