Skip to content

Commit

Permalink
Refactor domain client update and describe for crossdc
Browse files Browse the repository at this point in the history
  • Loading branch information
vancexu committed Apr 26, 2018
1 parent e428f15 commit 7ad84f4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 50 deletions.
13 changes: 6 additions & 7 deletions client/client.go
Expand Up @@ -259,23 +259,22 @@ type (
// - InternalServiceError
Register(ctx context.Context, request *s.RegisterDomainRequest) error

// Describe a domain. The domain has two part of information.
// DomainInfo - Which has Name, Status, Description, Owner Email.
// Describe a domain. The domain has 3 part of information
// DomainInfo - Which has Name, Status, Description, Owner Email
// DomainConfiguration - Configuration like Workflow Execution Retention Period In Days, Whether to emit metrics.
// ReplicationConfiguration - replication config like clusters and active cluster name
// The errors it can throw:
// - EntityNotExistsError
// - BadRequestError
// - InternalServiceError
Describe(ctx context.Context, name string) (*s.DomainInfo, *s.DomainConfiguration, error)
Describe(ctx context.Context, name string) (*s.DescribeDomainResponse, error)

// Update a domain. The domain has two part of information.
// UpdateDomainInfo - To update domain Description and Owner Email.
// DomainConfiguration - Configuration like Workflow Execution Retention Period In Days, Whether to emit metrics.
// Update a domain.
// The errors it can throw:
// - EntityNotExistsError
// - BadRequestError
// - InternalServiceError
Update(ctx context.Context, name string, domainInfo *s.UpdateDomainInfo, domainConfig *s.DomainConfiguration) error
Update(ctx context.Context, request *s.UpdateDomainRequest) error
}
)

Expand Down
13 changes: 6 additions & 7 deletions internal/client.go
Expand Up @@ -285,23 +285,22 @@ type (
// - InternalServiceError
Register(ctx context.Context, request *s.RegisterDomainRequest) error

// Describe a domain. The domain has two part of information.
// DomainInfo - Which has Name, Status, Description, Owner Email.
// Describe a domain. The domain has 3 part of information
// DomainInfo - Which has Name, Status, Description, Owner Email
// DomainConfiguration - Configuration like Workflow Execution Retention Period In Days, Whether to emit metrics.
// ReplicationConfiguration - replication config like clusters and active cluster name
// The errors it can throw:
// - EntityNotExistsError
// - BadRequestError
// - InternalServiceError
Describe(ctx context.Context, name string) (*s.DomainInfo, *s.DomainConfiguration, error)
Describe(ctx context.Context, name string) (*s.DescribeDomainResponse, error)

// Update a domain. The domain has two part of information.
// UpdateDomainInfo - To update domain Description and Owner Email.
// DomainConfiguration - Configuration like Workflow Execution Retention Period In Days, Whether to emit metrics.
// Update a domain.
// The errors it can throw:
// - EntityNotExistsError
// - BadRequestError
// - InternalServiceError
Update(ctx context.Context, name string, domainInfo *s.UpdateDomainInfo, domainConfig *s.DomainConfiguration) error
Update(ctx context.Context, request *s.UpdateDomainRequest) error
}

// WorkflowIDReusePolicy defines workflow ID reuse behavior.
Expand Down
21 changes: 7 additions & 14 deletions internal/internal_workflow_client.go
Expand Up @@ -656,14 +656,15 @@ func (dc *domainClient) Register(ctx context.Context, request *s.RegisterDomainR
}, serviceOperationRetryPolicy, isServiceTransientError)
}

// Describe a domain. The domain has two part of information
// Describe a domain. The domain has 3 part of information
// DomainInfo - Which has Name, Status, Description, Owner Email
// DomainConfiguration - Configuration like Workflow Execution Retention Period In Days, Whether to emit metrics.
// ReplicationConfiguration - replication config like clusters and active cluster name
// The errors it can throw:
// - EntityNotExistsError
// - BadRequestError
// - InternalServiceError
func (dc *domainClient) Describe(ctx context.Context, name string) (*s.DomainInfo, *s.DomainConfiguration, error) {
func (dc *domainClient) Describe(ctx context.Context, name string) (*s.DescribeDomainResponse, error) {
request := &s.DescribeDomainRequest{
Name: common.StringPtr(name),
}
Expand All @@ -678,25 +679,17 @@ func (dc *domainClient) Describe(ctx context.Context, name string) (*s.DomainInf
return err
}, serviceOperationRetryPolicy, isServiceTransientError)
if err != nil {
return nil, nil, err
return nil, err
}
return response.DomainInfo, response.Configuration, nil
return response, nil
}

// Update a domain. The domain has two part of information
// DomainInfo - Which has Name, Status, Description, Owner Email
// DomainConfiguration - Configuration like Workflow Execution Retention Period In Days, Whether to emit metrics.
// Update a domain.
// The errors it can throw:
// - EntityNotExistsError
// - BadRequestError
// - InternalServiceError
func (dc *domainClient) Update(ctx context.Context, name string, domainInfo *s.UpdateDomainInfo, domainConfig *s.DomainConfiguration) error {
request := &s.UpdateDomainRequest{
Name: common.StringPtr(name),
UpdatedInfo: domainInfo,
Configuration: domainConfig,
}

func (dc *domainClient) Update(ctx context.Context, request *s.UpdateDomainRequest) error {
return backoff.Retry(ctx,
func() error {
tchCtx, cancel, opt := newChannelContext(ctx)
Expand Down
35 changes: 13 additions & 22 deletions mocks/DomainClient.go

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

0 comments on commit 7ad84f4

Please sign in to comment.