Skip to content

Commit

Permalink
Rename domain to namespace. (#81)
Browse files Browse the repository at this point in the history
Due to circular runtime dependency with the service integration tests cannot pass with backward incompatible change like this one.
  • Loading branch information
alexshtin authored Mar 28, 2020
1 parent e8af96e commit 3db2adb
Show file tree
Hide file tree
Showing 44 changed files with 485 additions and 486 deletions.
52 changes: 26 additions & 26 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ const (
// DefaultHostPort is the host:port which is used if not passed with options.
DefaultHostPort = internal.LocalHostPort

// DefaultDomainName is the domain name which is used if not passed with options.
DefaultDomainName = internal.DefaultDomainName
// DefaultNamespace is the namespace name which is used if not passed with options.
DefaultNamespace = internal.DefaultNamespace

// QueryTypeStackTrace is the build in query type for Client.QueryWorkflow() call. Use this query type to get the call
// stack of the workflow. The result will be a string encoded in the encoded.Value.
Expand Down Expand Up @@ -92,7 +92,7 @@ type (
// or
// ExecuteWorkflow(ctx, options, workflowExecuteFn, arg1, arg2, arg3)
// The errors it can return:
// - EntityNotExistsError, if domain does not exists
// - EntityNotExistsError, if namespace does not exists
// - BadRequestError
// - InternalServiceError
//
Expand Down Expand Up @@ -144,7 +144,7 @@ type (
// Note: options.WorkflowIDReusePolicy is default to WorkflowIDReusePolicyAllowDuplicate in this API;
// while in StartWorkflow/ExecuteWorkflow APIs it is default to WorkflowIdReusePolicyAllowDuplicateFailedOnly.
// The errors it can return:
// - EntityNotExistsError, if domain does not exist
// - EntityNotExistsError, if namespace does not exist
// - BadRequestError
// - InternalServiceError
SignalWithStartWorkflow(ctx context.Context, workflowID string, signalName string, signalArg interface{},
Expand Down Expand Up @@ -214,12 +214,12 @@ type (
// completed event will be reported; if err is CanceledError, activity task cancelled event will be reported; otherwise,
// activity task failed event will be reported.
// An activity implementation should use activityID provided in ActivityOption to use for completion.
// domain name, workflowID, activityID are required, runID is optional.
// namespace name, workflowID, activityID are required, runID is optional.
// The errors it can return:
// - ErrorWithDetails
// - TimeoutError
// - CanceledError
CompleteActivityByID(ctx context.Context, domain, workflowID, runID, activityID string, result interface{}, err error) error
CompleteActivityByID(ctx context.Context, namespace, workflowID, runID, activityID string, result interface{}, err error) error

// RecordActivityHeartbeat records heartbeat for an activity.
// taskToken - is the value of the binary "TaskToken" field of the "ActivityInfo" struct retrieved inside the activity.
Expand All @@ -234,7 +234,7 @@ type (
// The errors it can return:
// - EntityNotExistsError
// - InternalServiceError
RecordActivityHeartbeatByID(ctx context.Context, domain, workflowID, runID, activityID string, details ...interface{}) error
RecordActivityHeartbeatByID(ctx context.Context, namespace, workflowID, runID, activityID string, details ...interface{}) error

// ListClosedWorkflow gets closed workflow executions based on request filters.
// Retrieved workflow executions are sorted by start time in descending order.
Expand Down Expand Up @@ -270,9 +270,9 @@ type (
ListWorkflow(ctx context.Context, request *workflowservice.ListWorkflowExecutionsRequest) (*workflowservice.ListWorkflowExecutionsResponse, error)

// ListArchivedWorkflow gets archived workflow executions based on query. This API will return BadRequest if Temporal
// cluster or target domain is not configured for visibility archival or read is not enabled. The query is basically the SQL WHERE clause.
// cluster or target namespace is not configured for visibility archival or read is not enabled. The query is basically the SQL WHERE clause.
// However, different visibility archivers have different limitations on the query. Please check the documentation of the visibility archiver used
// by your domain to see what kind of queries are accept and whether retrieved workflow executions are ordered or not.
// by your namespace to see what kind of queries are accept and whether retrieved workflow executions are ordered or not.
// The errors it can return:
// - BadRequestError
// - InternalServiceError
Expand Down Expand Up @@ -352,32 +352,32 @@ type (
CloseConnection() error
}

// DomainClient is the client for managing operations on the domain.
// CLI, tools, ... can use this layer to manager operations on domain.
DomainClient interface {
// Register a domain with temporal server
// NamespaceClient is the client for managing operations on the namespace.
// CLI, tools, ... can use this layer to manager operations on namespace.
NamespaceClient interface {
// Register a namespace with temporal server
// The errors it can throw:
// - DomainAlreadyExistsError
// - NamespaceAlreadyExistsError
// - BadRequestError
// - InternalServiceError
Register(ctx context.Context, request *workflowservice.RegisterDomainRequest) error
Register(ctx context.Context, request *workflowservice.RegisterNamespaceRequest) error

// 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.
// Describe a namespace. The namespace has 3 part of information
// NamespaceInfo - Which has Name, Status, Description, Owner Email
// NamespaceConfiguration - 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) (*workflowservice.DescribeDomainResponse, error)
Describe(ctx context.Context, name string) (*workflowservice.DescribeNamespaceResponse, error)

// Update a domain.
// Update a namespace.
// The errors it can throw:
// - EntityNotExistsError
// - BadRequestError
// - InternalServiceError
Update(ctx context.Context, request *workflowservice.UpdateDomainRequest) error
Update(ctx context.Context, request *workflowservice.UpdateNamespaceRequest) error

// CloseConnection closes underlying gRPC connection.
CloseConnection() error
Expand Down Expand Up @@ -412,16 +412,16 @@ func NewClient(options Options) (Client, error) {
return internal.NewClient(options)
}

// NewDomainClient creates an instance of a domain client, to manage lifecycle of domains.
func NewDomainClient(options Options) (DomainClient, error) {
return internal.NewDomainClient(options)
// NewNamespaceClient creates an instance of a namespace client, to manage lifecycle of namespaces.
func NewNamespaceClient(options Options) (NamespaceClient, error) {
return internal.NewNamespaceClient(options)
}

// make sure if new methods are added to internal.Client they are also added to public Client.
var _ Client = internal.Client(nil)
var _ internal.Client = Client(nil)
var _ DomainClient = internal.DomainClient(nil)
var _ internal.DomainClient = DomainClient(nil)
var _ NamespaceClient = internal.NamespaceClient(nil)
var _ internal.NamespaceClient = NamespaceClient(nil)

// NewValue creates a new encoded.Value which can be used to decode binary data returned by Temporal. For example:
// User had Activity.RecordHeartbeat(ctx, "my-heartbeat") and then got response from calling Client.DescribeWorkflowExecution.
Expand Down
2 changes: 1 addition & 1 deletion evictiontest/workflow_cache_eviction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (s *CacheEvictionSuite) TestResetStickyOnEviction() {
cacheSize := 5
internal.SetStickyWorkflowCacheSize(cacheSize)
// once for workflow worker because we disable activity worker
s.service.EXPECT().DescribeDomain(gomock.Any(), gomock.Any()).Return(nil, nil).Times(1)
s.service.EXPECT().DescribeNamespace(gomock.Any(), gomock.Any()).Return(nil, nil).Times(1)
// feed our worker exactly *cacheSize* "legit" decision tasks
// these are handcrafted decision tasks that are not blatantly obviously mocks
// the goal is to trick our worker into thinking they are real so it
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/uber-go/tally v3.3.15+incompatible
github.com/uber/jaeger-client-go v2.22.1+incompatible
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
go.temporal.io/temporal-proto v0.20.1
go.temporal.io/temporal-proto v0.20.2
go.uber.org/atomic v1.6.0
go.uber.org/goleak v1.0.0
go.uber.org/zap v1.14.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ github.com/uber/jaeger-client-go v2.22.1+incompatible/go.mod h1:WVhlPFC8FDjOFMMW
github.com/uber/jaeger-lib v2.2.0+incompatible h1:MxZXOiR2JuoANZ3J6DE/U0kSFv/eJ/GfSYVCjK7dyaw=
github.com/uber/jaeger-lib v2.2.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.temporal.io/temporal-proto v0.20.1 h1:hiu9DbQVYOZDp3IVkn0wCahIN6iQR429ctVXcUCARBw=
go.temporal.io/temporal-proto v0.20.1/go.mod h1:Lv8L8YBpbp0Z7V5nbvw5UD0j7x0isebhCOIDLkBqn6s=
go.temporal.io/temporal-proto v0.20.2 h1:ll+VJaxyR4xzZWClT+CIcm4fQdzEdcBGf4Yksq4EVxI=
go.temporal.io/temporal-proto v0.20.2/go.mod h1:Lv8L8YBpbp0Z7V5nbvw5UD0j7x0isebhCOIDLkBqn6s=
go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/goleak v1.0.0 h1:qsup4IcBdlmsnGfqyLl4Ntn3C2XCCuKAE7DwHpScyUo=
Expand Down
8 changes: 4 additions & 4 deletions internal/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type (
ActivityInfo struct {
TaskToken []byte
WorkflowType *WorkflowType
WorkflowDomain string
WorkflowNamespace string
WorkflowExecution WorkflowExecution
ActivityID string
ActivityType ActivityType
Expand Down Expand Up @@ -134,7 +134,7 @@ func GetActivityInfo(ctx context.Context) ActivityInfo {
TaskList: env.taskList,
Attempt: env.attempt,
WorkflowType: env.workflowType,
WorkflowDomain: env.workflowDomain,
WorkflowNamespace: env.workflowNamespace,
}
}

Expand Down Expand Up @@ -215,7 +215,7 @@ type ServiceInvoker interface {
// Returns ActivityTaskCanceledError if activity is cancelled
Heartbeat(details []byte) error
Close(flushBufferedHeartbeat bool)
GetClient(domain string, options ClientOptions) Client
GetClient(namespace string, options ClientOptions) Client
}

// WithActivityTask adds activity specific information into context.
Expand Down Expand Up @@ -276,7 +276,7 @@ func WithActivityTask(
workflowType: &WorkflowType{
Name: task.WorkflowType.Name,
},
workflowDomain: task.WorkflowDomain,
workflowNamespace: task.WorkflowNamespace,
workerStopChannel: workerStopChannel,
contextPropagators: contextPropagators,
tracer: tracer,
Expand Down
Loading

0 comments on commit 3db2adb

Please sign in to comment.