Skip to content

Commit

Permalink
Add namespace_id field to events with namespace field (#2903)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexshtin committed May 27, 2022
1 parent 9b8cadc commit 738b36f
Show file tree
Hide file tree
Showing 27 changed files with 708 additions and 484 deletions.
470 changes: 263 additions & 207 deletions api/persistence/v1/executions.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion common/testing/history_event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestHistoryEventTestSuite(t *testing.T) {
}

func (s *historyEventTestSuit) SetupSuite() {
s.generator = InitializeHistoryEventGenerator("namespace", 1)
s.generator = InitializeHistoryEventGenerator("namespace", "ns-id", 1)
}

func (s *historyEventTestSuit) SetupTest() {
Expand Down
46 changes: 31 additions & 15 deletions common/testing/history_event_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
taskqueuepb "go.temporal.io/api/taskqueue/v1"

"go.temporal.io/server/common/failure"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/primitives/timestamp"
)

Expand All @@ -58,7 +59,8 @@ var (

// InitializeHistoryEventGenerator initializes the history event generator
func InitializeHistoryEventGenerator(
namespace string,
nsName namespace.Name,
nsID namespace.ID,
defaultVersion int64,
) Generator {

Expand Down Expand Up @@ -606,7 +608,8 @@ func InitializeHistoryEventGenerator(
historyEvent := getDefaultHistoryEvent(eventID, version)
historyEvent.EventType = enumspb.EVENT_TYPE_START_CHILD_WORKFLOW_EXECUTION_INITIATED
historyEvent.Attributes = &historypb.HistoryEvent_StartChildWorkflowExecutionInitiatedEventAttributes{StartChildWorkflowExecutionInitiatedEventAttributes: &historypb.StartChildWorkflowExecutionInitiatedEventAttributes{
Namespace: namespace,
Namespace: nsName.String(),
NamespaceId: nsID.String(),
WorkflowId: childWorkflowID,
WorkflowType: &commonpb.WorkflowType{Name: childWorkflowPrefix + workflowType},
TaskQueue: &taskqueuepb.TaskQueue{
Expand All @@ -630,7 +633,8 @@ func InitializeHistoryEventGenerator(
historyEvent := getDefaultHistoryEvent(eventID, version)
historyEvent.EventType = enumspb.EVENT_TYPE_START_CHILD_WORKFLOW_EXECUTION_FAILED
historyEvent.Attributes = &historypb.HistoryEvent_StartChildWorkflowExecutionFailedEventAttributes{StartChildWorkflowExecutionFailedEventAttributes: &historypb.StartChildWorkflowExecutionFailedEventAttributes{
Namespace: namespace,
Namespace: nsName.String(),
NamespaceId: nsID.String(),
WorkflowId: childWorkflowID,
WorkflowType: &commonpb.WorkflowType{Name: childWorkflowPrefix + workflowType},
Cause: enumspb.START_CHILD_WORKFLOW_EXECUTION_FAILED_CAUSE_WORKFLOW_ALREADY_EXISTS,
Expand All @@ -648,7 +652,8 @@ func InitializeHistoryEventGenerator(
historyEvent := getDefaultHistoryEvent(eventID, version)
historyEvent.EventType = enumspb.EVENT_TYPE_CHILD_WORKFLOW_EXECUTION_STARTED
historyEvent.Attributes = &historypb.HistoryEvent_ChildWorkflowExecutionStartedEventAttributes{ChildWorkflowExecutionStartedEventAttributes: &historypb.ChildWorkflowExecutionStartedEventAttributes{
Namespace: namespace,
Namespace: nsName.String(),
NamespaceId: nsID.String(),
WorkflowType: &commonpb.WorkflowType{Name: childWorkflowPrefix + workflowType},
InitiatedEventId: lastEvent.EventId,
WorkflowExecution: &commonpb.WorkflowExecution{
Expand All @@ -667,7 +672,8 @@ func InitializeHistoryEventGenerator(
historyEvent := getDefaultHistoryEvent(eventID, version)
historyEvent.EventType = enumspb.EVENT_TYPE_CHILD_WORKFLOW_EXECUTION_CANCELED
historyEvent.Attributes = &historypb.HistoryEvent_ChildWorkflowExecutionCanceledEventAttributes{ChildWorkflowExecutionCanceledEventAttributes: &historypb.ChildWorkflowExecutionCanceledEventAttributes{
Namespace: namespace,
Namespace: nsName.String(),
NamespaceId: nsID.String(),
WorkflowType: &commonpb.WorkflowType{Name: childWorkflowPrefix + workflowType},
InitiatedEventId: lastEvent.GetChildWorkflowExecutionStartedEventAttributes().InitiatedEventId,
WorkflowExecution: &commonpb.WorkflowExecution{
Expand All @@ -687,7 +693,8 @@ func InitializeHistoryEventGenerator(
historyEvent := getDefaultHistoryEvent(eventID, version)
historyEvent.EventType = enumspb.EVENT_TYPE_CHILD_WORKFLOW_EXECUTION_COMPLETED
historyEvent.Attributes = &historypb.HistoryEvent_ChildWorkflowExecutionCompletedEventAttributes{ChildWorkflowExecutionCompletedEventAttributes: &historypb.ChildWorkflowExecutionCompletedEventAttributes{
Namespace: namespace,
Namespace: nsName.String(),
NamespaceId: nsID.String(),
WorkflowType: &commonpb.WorkflowType{Name: childWorkflowPrefix + workflowType},
InitiatedEventId: lastEvent.GetChildWorkflowExecutionStartedEventAttributes().InitiatedEventId,
WorkflowExecution: &commonpb.WorkflowExecution{
Expand All @@ -707,7 +714,8 @@ func InitializeHistoryEventGenerator(
historyEvent := getDefaultHistoryEvent(eventID, version)
historyEvent.EventType = enumspb.EVENT_TYPE_CHILD_WORKFLOW_EXECUTION_FAILED
historyEvent.Attributes = &historypb.HistoryEvent_ChildWorkflowExecutionFailedEventAttributes{ChildWorkflowExecutionFailedEventAttributes: &historypb.ChildWorkflowExecutionFailedEventAttributes{
Namespace: namespace,
Namespace: nsName.String(),
NamespaceId: nsID.String(),
WorkflowType: &commonpb.WorkflowType{Name: childWorkflowPrefix + workflowType},
InitiatedEventId: lastEvent.GetChildWorkflowExecutionStartedEventAttributes().InitiatedEventId,
WorkflowExecution: &commonpb.WorkflowExecution{
Expand All @@ -727,7 +735,8 @@ func InitializeHistoryEventGenerator(
historyEvent := getDefaultHistoryEvent(eventID, version)
historyEvent.EventType = enumspb.EVENT_TYPE_CHILD_WORKFLOW_EXECUTION_TERMINATED
historyEvent.Attributes = &historypb.HistoryEvent_ChildWorkflowExecutionTerminatedEventAttributes{ChildWorkflowExecutionTerminatedEventAttributes: &historypb.ChildWorkflowExecutionTerminatedEventAttributes{
Namespace: namespace,
Namespace: nsName.String(),
NamespaceId: nsID.String(),
WorkflowType: &commonpb.WorkflowType{Name: childWorkflowPrefix + workflowType},
InitiatedEventId: lastEvent.GetChildWorkflowExecutionStartedEventAttributes().InitiatedEventId,
WorkflowExecution: &commonpb.WorkflowExecution{
Expand All @@ -747,7 +756,8 @@ func InitializeHistoryEventGenerator(
historyEvent := getDefaultHistoryEvent(eventID, version)
historyEvent.EventType = enumspb.EVENT_TYPE_CHILD_WORKFLOW_EXECUTION_TIMED_OUT
historyEvent.Attributes = &historypb.HistoryEvent_ChildWorkflowExecutionTimedOutEventAttributes{ChildWorkflowExecutionTimedOutEventAttributes: &historypb.ChildWorkflowExecutionTimedOutEventAttributes{
Namespace: namespace,
Namespace: nsName.String(),
NamespaceId: nsID.String(),
WorkflowType: &commonpb.WorkflowType{Name: childWorkflowPrefix + workflowType},
InitiatedEventId: lastEvent.GetChildWorkflowExecutionStartedEventAttributes().InitiatedEventId,
WorkflowExecution: &commonpb.WorkflowExecution{
Expand Down Expand Up @@ -797,7 +807,8 @@ func InitializeHistoryEventGenerator(
historyEvent.EventType = enumspb.EVENT_TYPE_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_INITIATED
historyEvent.Attributes = &historypb.HistoryEvent_SignalExternalWorkflowExecutionInitiatedEventAttributes{SignalExternalWorkflowExecutionInitiatedEventAttributes: &historypb.SignalExternalWorkflowExecutionInitiatedEventAttributes{
WorkflowTaskCompletedEventId: lastEvent.EventId,
Namespace: namespace,
Namespace: nsName.String(),
NamespaceId: nsID.String(),
WorkflowExecution: &commonpb.WorkflowExecution{
WorkflowId: externalWorkflowID,
RunId: uuid.New(),
Expand All @@ -818,7 +829,8 @@ func InitializeHistoryEventGenerator(
historyEvent.Attributes = &historypb.HistoryEvent_SignalExternalWorkflowExecutionFailedEventAttributes{SignalExternalWorkflowExecutionFailedEventAttributes: &historypb.SignalExternalWorkflowExecutionFailedEventAttributes{
Cause: enumspb.SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_EXTERNAL_WORKFLOW_EXECUTION_NOT_FOUND,
WorkflowTaskCompletedEventId: lastEvent.GetSignalExternalWorkflowExecutionInitiatedEventAttributes().WorkflowTaskCompletedEventId,
Namespace: namespace,
Namespace: nsName.String(),
NamespaceId: nsID.String(),
WorkflowExecution: &commonpb.WorkflowExecution{
WorkflowId: lastEvent.GetSignalExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().WorkflowId,
RunId: lastEvent.GetSignalExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().RunId,
Expand All @@ -837,7 +849,8 @@ func InitializeHistoryEventGenerator(
historyEvent.EventType = enumspb.EVENT_TYPE_EXTERNAL_WORKFLOW_EXECUTION_SIGNALED
historyEvent.Attributes = &historypb.HistoryEvent_ExternalWorkflowExecutionSignaledEventAttributes{ExternalWorkflowExecutionSignaledEventAttributes: &historypb.ExternalWorkflowExecutionSignaledEventAttributes{
InitiatedEventId: lastEvent.EventId,
Namespace: namespace,
Namespace: nsName.String(),
NamespaceId: nsID.String(),
WorkflowExecution: &commonpb.WorkflowExecution{
WorkflowId: lastEvent.GetSignalExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().WorkflowId,
RunId: lastEvent.GetSignalExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().RunId,
Expand All @@ -856,7 +869,8 @@ func InitializeHistoryEventGenerator(
historyEvent.Attributes = &historypb.HistoryEvent_RequestCancelExternalWorkflowExecutionInitiatedEventAttributes{
RequestCancelExternalWorkflowExecutionInitiatedEventAttributes: &historypb.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes{
WorkflowTaskCompletedEventId: lastEvent.EventId,
Namespace: namespace,
Namespace: nsName.String(),
NamespaceId: nsID.String(),
WorkflowExecution: &commonpb.WorkflowExecution{
WorkflowId: externalWorkflowID,
RunId: uuid.New(),
Expand All @@ -876,7 +890,8 @@ func InitializeHistoryEventGenerator(
historyEvent.Attributes = &historypb.HistoryEvent_RequestCancelExternalWorkflowExecutionFailedEventAttributes{RequestCancelExternalWorkflowExecutionFailedEventAttributes: &historypb.RequestCancelExternalWorkflowExecutionFailedEventAttributes{
Cause: enumspb.CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_EXTERNAL_WORKFLOW_EXECUTION_NOT_FOUND,
WorkflowTaskCompletedEventId: lastEvent.GetRequestCancelExternalWorkflowExecutionInitiatedEventAttributes().WorkflowTaskCompletedEventId,
Namespace: namespace,
Namespace: nsName.String(),
NamespaceId: nsID.String(),
WorkflowExecution: &commonpb.WorkflowExecution{
WorkflowId: lastEvent.GetRequestCancelExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().WorkflowId,
RunId: lastEvent.GetRequestCancelExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().RunId,
Expand All @@ -895,7 +910,8 @@ func InitializeHistoryEventGenerator(
historyEvent.EventType = enumspb.EVENT_TYPE_EXTERNAL_WORKFLOW_EXECUTION_CANCEL_REQUESTED
historyEvent.Attributes = &historypb.HistoryEvent_ExternalWorkflowExecutionCancelRequestedEventAttributes{ExternalWorkflowExecutionCancelRequestedEventAttributes: &historypb.ExternalWorkflowExecutionCancelRequestedEventAttributes{
InitiatedEventId: lastEvent.EventId,
Namespace: namespace,
Namespace: nsName.String(),
NamespaceId: nsID.String(),
WorkflowExecution: &commonpb.WorkflowExecution{
WorkflowId: lastEvent.GetRequestCancelExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().WorkflowId,
RunId: lastEvent.GetRequestCancelExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().RunId,
Expand Down
33 changes: 15 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module go.temporal.io/server
go 1.18

require (
cloud.google.com/go/storage v1.22.0
cloud.google.com/go/storage v1.22.1
github.com/aws/aws-sdk-go v1.43.38
github.com/aws/aws-sdk-go-v2 v1.16.3
github.com/aws/aws-sdk-go-v2/config v1.15.5
Expand Down Expand Up @@ -40,18 +40,18 @@ require (
go.opentelemetry.io/otel/metric v0.29.0
go.opentelemetry.io/otel/sdk v1.6.3
go.opentelemetry.io/otel/sdk/metric v0.29.0
go.temporal.io/api v1.7.1-0.20220510183009-449d18444c9a
go.temporal.io/api v1.7.1-0.20220527042911-3de1acf95864
go.temporal.io/sdk v1.14.1-0.20220513214234-7ccfda678fed
go.temporal.io/version v0.3.0
go.uber.org/atomic v1.9.0
go.uber.org/fx v1.17.1
go.uber.org/multierr v1.8.0
go.uber.org/zap v1.21.0
golang.org/x/exp v0.0.0-20220428152302-39d4317da171
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5
golang.org/x/oauth2 v0.0.0-20220524215830-622c5d57e401
golang.org/x/time v0.0.0-20220411224347-583f2d630306
google.golang.org/api v0.74.0
google.golang.org/grpc v1.46.0
google.golang.org/api v0.81.0
google.golang.org/grpc v1.46.2
google.golang.org/grpc/examples v0.0.0-20220412212246-3bf6719fc8ab
gopkg.in/square/go-jose.v2 v2.6.0
gopkg.in/validator.v2 v2.0.1
Expand All @@ -60,6 +60,10 @@ require (
)

require (
cloud.google.com/go v0.102.0 // indirect
cloud.google.com/go/compute v1.6.1 // indirect
cloud.google.com/go/iam v0.3.0 // indirect
github.com/apache/thrift v0.0.0-20161221203622-b2a4d4ae21c7 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.12.0 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.4 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.10 // indirect
Expand All @@ -69,13 +73,6 @@ require (
github.com/aws/aws-sdk-go-v2/service/sso v1.11.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.16.4 // indirect
github.com/aws/smithy-go v1.11.2 // indirect
)

require (
cloud.google.com/go v0.100.2 // indirect
cloud.google.com/go/compute v1.5.0 // indirect
cloud.google.com/go/iam v0.3.0 // indirect
github.com/apache/thrift v0.0.0-20161221203622-b2a4d4ae21c7 // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
Expand All @@ -89,8 +86,8 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.5.7 // indirect
github.com/googleapis/gax-go/v2 v2.3.0 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/googleapis/gax-go/v2 v2.4.0 // indirect
github.com/googleapis/go-type-adapters v1.0.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
Expand Down Expand Up @@ -119,13 +116,13 @@ require (
go.uber.org/dig v1.14.1 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect
golang.org/x/net v0.0.0-20220526153639-5463443f8c37 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.10 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3 // indirect
google.golang.org/genproto v0.0.0-20220526192754-51939a95c655 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
lukechampine.com/uint128 v1.2.0 // indirect
Expand Down

0 comments on commit 738b36f

Please sign in to comment.