Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UNSPECIFIED to every enum #441

Merged
merged 5 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ clean-proto:

update-proto-submodule:
@printf $(COLOR) "Update proto submodule from remote..."
git submodule update --remote $(PROTO_ROOT)/temporal-proto
git submodule update --force --remote $(PROTO_ROOT)/temporal-proto

install-proto-submodule:
@printf $(COLOR) "Install proto submodule..."
Expand Down
58 changes: 58 additions & 0 deletions common/enums/defaults.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// The MIT License
//
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
//
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package enums
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All enums in this file are considered to be optional. If value is not set (i.e. set to UNSPECIFIED) some default value will be used.

Copy link
Contributor

@shawnhathaway shawnhathaway Jun 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reader Note: Ideally these are only used from within the grpc handlers of each service


import (
commonpb "go.temporal.io/temporal-proto/common"
filterpb "go.temporal.io/temporal-proto/filter"
querypb "go.temporal.io/temporal-proto/query"
tasklistpb "go.temporal.io/temporal-proto/tasklist"
)

func SetDefaultWorkflowIdReusePolicy(f *commonpb.WorkflowIdReusePolicy){
if *f == commonpb.WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED{
*f = commonpb.WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE
}
}

func SetDefaultHistoryEventFilterType(f *filterpb.HistoryEventFilterType){
if *f == filterpb.HISTORY_EVENT_FILTER_TYPE_UNSPECIFIED{
*f = filterpb.HISTORY_EVENT_FILTER_TYPE_ALL_EVENT
}
}

func SetDefaultTaskListKind(f *tasklistpb.TaskListKind){
if *f == tasklistpb.TASK_LIST_KIND_UNSPECIFIED{
*f = tasklistpb.TASK_LIST_KIND_NORMAL
}
}

// TODO: remove this with corresponding field from request
func SetDefaultQueryConsistencyLevel(f *querypb.QueryConsistencyLevel){
if *f == querypb.QUERY_CONSISTENCY_LEVEL_UNSPECIFIED{
*f = querypb.QUERY_CONSISTENCY_LEVEL_STRONG
}
}

12 changes: 6 additions & 6 deletions common/namespace/archivalConfigStateMachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ func (s *ArchivalState) getNextState(
URI: s.URI,
}, true, nil
}
if e.status == namespacepb.ARCHIVAL_STATUS_DEFAULT && eventURISet {
if e.status == namespacepb.ARCHIVAL_STATUS_UNSPECIFIED && eventURISet {
return s, false, nil
}
if e.status == namespacepb.ARCHIVAL_STATUS_DEFAULT && !eventURISet {
if e.status == namespacepb.ARCHIVAL_STATUS_UNSPECIFIED && !eventURISet {
return s, false, nil
}
}
Expand All @@ -197,10 +197,10 @@ func (s *ArchivalState) getNextState(
if e.status == namespacepb.ARCHIVAL_STATUS_DISABLED && !eventURISet {
return s, false, nil
}
if e.status == namespacepb.ARCHIVAL_STATUS_DEFAULT && eventURISet {
if e.status == namespacepb.ARCHIVAL_STATUS_UNSPECIFIED && eventURISet {
return s, false, nil
}
if e.status == namespacepb.ARCHIVAL_STATUS_DEFAULT && !eventURISet {
if e.status == namespacepb.ARCHIVAL_STATUS_UNSPECIFIED && !eventURISet {
return s, false, nil
}
}
Expand Down Expand Up @@ -228,13 +228,13 @@ func (s *ArchivalState) getNextState(
if e.status == namespacepb.ARCHIVAL_STATUS_DISABLED && !eventURISet {
return s, false, nil
}
if e.status == namespacepb.ARCHIVAL_STATUS_DEFAULT && eventURISet {
if e.status == namespacepb.ARCHIVAL_STATUS_UNSPECIFIED && eventURISet {
return &ArchivalState{
Status: namespacepb.ARCHIVAL_STATUS_DISABLED,
URI: e.URI,
}, true, nil
}
if e.status == namespacepb.ARCHIVAL_STATUS_DEFAULT && !eventURISet {
if e.status == namespacepb.ARCHIVAL_STATUS_UNSPECIFIED && !eventURISet {
return s, false, nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion common/namespace/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ func (d *HandlerImpl) toArchivalRegisterEvent(
URI: URI,
defaultURI: defaultURI,
}
if event.status == namespacepb.ARCHIVAL_STATUS_DEFAULT {
if event.status == namespacepb.ARCHIVAL_STATUS_UNSPECIFIED {
event.status = defaultStatus
}
if err := event.validate(); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ func (s *VisibilityPersistenceSuite) assertOpenExecutionEquals(
s.Equal(req.WorkflowTypeName, resp.GetType().GetName())
s.Equal(s.nanosToMillis(req.StartTimestamp), s.nanosToMillis(resp.GetStartTime().GetValue()))
s.Nil(resp.CloseTime)
s.Equal(resp.Status, executionpb.WORKFLOW_EXECUTION_STATUS_UNKNOWN)
s.Equal(resp.Status, executionpb.WORKFLOW_EXECUTION_STATUS_UNSPECIFIED)
s.Zero(resp.HistoryLength)
}

Expand Down
20 changes: 13 additions & 7 deletions common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,14 @@ func CreateHistoryStartWorkflowRequest(
histRequest := &historyservice.StartWorkflowExecutionRequest{
NamespaceId: namespaceID,
StartRequest: startRequest,
ContinueAsNewInitiator: commonpb.CONTINUE_AS_NEW_INITIATOR_DECIDER,
}
if startRequest.GetWorkflowExecutionTimeoutSeconds() > 0 {
expirationInSeconds := startRequest.GetWorkflowExecutionTimeoutSeconds()
deadline := now.Add(time.Second * time.Duration(expirationInSeconds))
histRequest.WorkflowExecutionExpirationTimestamp = deadline.Round(time.Millisecond).UnixNano()
}

histRequest.FirstDecisionTaskBackoffSeconds = backoff.GetBackoffForNextScheduleInSeconds(startRequest.GetCronSchedule(), now, now)
return histRequest
}
Expand Down Expand Up @@ -496,16 +498,20 @@ func IsJustOrderByClause(clause string) bool {
func ConvertIndexedValueTypeToProtoType(fieldType interface{}, logger log.Logger) commonpb.IndexedValueType {
switch t := fieldType.(type) {
case float64:
return commonpb.IndexedValueType(fieldType.(float64))
return commonpb.IndexedValueType(t)
case int:
return commonpb.IndexedValueType(fieldType.(int))
return commonpb.IndexedValueType(t)
case string:
if ivt, ok := commonpb.IndexedValueType_value[t]; ok{
return commonpb.IndexedValueType(ivt)
}
case commonpb.IndexedValueType:
return fieldType.(commonpb.IndexedValueType)
default:
// Unknown fieldType, please make sure dynamic config return correct value type
logger.Error("unknown index value type", tag.Value(fieldType), tag.ValueType(t))
return fieldType.(commonpb.IndexedValueType) // it will panic and been captured by logger
return t
}

// Unknown fieldType, please make sure dynamic config return correct value type
logger.Error("unknown index value type", tag.Value(fieldType), tag.ValueType(fieldType))
return fieldType.(commonpb.IndexedValueType) // it will panic and been captured by logger
}

// DeserializeSearchAttributeValue takes json encoded search attribute value and it's type as input, then
Expand Down
54 changes: 27 additions & 27 deletions config/dynamicconfig/development_es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ system.enableReadVisibilityFromES:
- value: true
frontend.validSearchAttributes:
- value:
NamespaceId: 1
WorkflowId: 1
RunId: 1
WorkflowType: 1
StartTime: 2
ExecutionTime: 2
CloseTime: 2
Status: 2
HistoryLength: 2
TaskList: 1
CustomStringField: 0
CustomKeywordField: 1
CustomIntField: 2
CustomDoubleField: 3
CustomBoolField: 4
CustomDatetimeField: 5
project: 1
service: 1
environment: 1
addon: 1
addon-type: 1
user: 1
CustomNamespace: 1
Operator: 1
RolloutId: 1
TemporalChangeVersion: 1
BinaryChecksums: 1
NamespaceId: "Keyword"
WorkflowId: "Keyword"
RunId: "Keyword"
WorkflowType: "Keyword"
StartTime: "Int"
ExecutionTime: "Int"
CloseTime: "Int"
Status: "Int"
HistoryLength: "Int"
TaskList: "Keyword"
CustomStringField: "String"
CustomKeywordField: "Keyword"
CustomIntField: "Int"
CustomDoubleField: "Double"
CustomBoolField: "Bool"
CustomDatetimeField: "Datetime"
project: "Keyword"
service: "Keyword"
environment: "Keyword"
addon: "Keyword"
addon-type: "Keyword"
user: "Keyword"
CustomNamespace: "Keyword"
Operator: "Keyword"
RolloutId: "Keyword"
TemporalChangeVersion: "Keyword"
BinaryChecksums: "Keyword"
system.minRetentionDays:
- value: 0
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ require (
github.com/urfave/cli v1.22.4
github.com/valyala/fastjson v1.5.1
github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
go.temporal.io/temporal v0.23.9
go.temporal.io/temporal-proto v0.23.6
go.temporal.io/temporal v0.24.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👯

go.temporal.io/temporal-proto v0.24.0
go.uber.org/atomic v1.6.0
go.uber.org/multierr v1.5.0
go.uber.org/zap v1.15.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,10 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3 h1:8sGtKOrtQqkN1bp2AtX+misvLIlOmsEsNd+9NIcPEm8=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.temporal.io/temporal v0.23.9 h1:I4gdSOG6EpaSR+OcQOZNBhKh+r9Gg+hL3oKd4QyF9fA=
go.temporal.io/temporal v0.23.9/go.mod h1:ptzw4JsjferONM4ICA1+rPU23J8fU2SJS6vw4I3+AWA=
go.temporal.io/temporal-proto v0.23.6 h1:MHUDqJB2nptBSjZcDZMt/vv1rC8L0grTvwoRYHJwAG0=
go.temporal.io/temporal-proto v0.23.6/go.mod h1:lFt53MEhtjHIJtgg1U1Fdx3e3HoBOZcZKEbElzYz5Ro=
go.temporal.io/temporal v0.24.0 h1:RUvCkhnzJPaIH2n+LLvJik/4pFssrPuLDK3XWSmmd14=
go.temporal.io/temporal v0.24.0/go.mod h1:fZp1hbnfmFfZTx3IzVo4OWFKJRvp5HLeGdw6MdKURu4=
go.temporal.io/temporal-proto v0.24.0 h1:4fHSBv4PIJuRJAU6l5ANrp9tOvXVB1c1mfShKYbpzlI=
go.temporal.io/temporal-proto v0.24.0/go.mod h1:lFt53MEhtjHIJtgg1U1Fdx3e3HoBOZcZKEbElzYz5Ro=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
Expand Down
3 changes: 3 additions & 0 deletions host/ndc/nDC_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ func (s *nDCIntegrationTestSuite) TestHandcraftedMultipleBranches() {
WorkflowRunTimeoutSeconds: 1000,
WorkflowTaskTimeoutSeconds: 1000,
FirstDecisionTaskBackoffSeconds: 100,
Initiator: commonpb.CONTINUE_AS_NEW_INITIATOR_DECIDER,
}},
},
{
Expand Down Expand Up @@ -713,6 +714,7 @@ func (s *nDCIntegrationTestSuite) TestHandcraftedMultipleBranchesWithZombieConti
WorkflowRunTimeoutSeconds: 1000,
WorkflowTaskTimeoutSeconds: 1000,
FirstDecisionTaskBackoffSeconds: 100,
Initiator: commonpb.CONTINUE_AS_NEW_INITIATOR_DECIDER,
}},
},
{
Expand Down Expand Up @@ -1182,6 +1184,7 @@ func (s *nDCIntegrationTestSuite) TestAdminGetWorkflowExecutionRawHistoryV2() {
WorkflowRunTimeoutSeconds: 1000,
WorkflowTaskTimeoutSeconds: 1000,
FirstDecisionTaskBackoffSeconds: 100,
Initiator: commonpb.CONTINUE_AS_NEW_INITIATOR_DECIDER,
}},
},
{
Expand Down
15 changes: 8 additions & 7 deletions host/queryworkflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ func (s *integrationSuite) TestQueryWorkflow_NonSticky() {
}

// call QueryWorkflow in separate goroutinue (because it is blocking). That will generate a query task
go queryWorkflowFn(queryType, querypb.QUERY_REJECT_CONDITION_NONE)
go queryWorkflowFn(queryType, querypb.QUERY_REJECT_CONDITION_UNSPECIFIED)
// process that query task, which should respond via RespondQueryTaskCompleted
for {
// loop until process the query task
Expand All @@ -494,7 +494,7 @@ func (s *integrationSuite) TestQueryWorkflow_NonSticky() {
s.NoError(err)
s.Equal("query-result", queryResultString)

go queryWorkflowFn("invalid-query-type", querypb.QUERY_REJECT_CONDITION_NONE)
go queryWorkflowFn("invalid-query-type", querypb.QUERY_REJECT_CONDITION_UNSPECIFIED)
for {
// loop until process the query task
isQueryTask, errInner := poller.PollAndProcessDecisionTask(false, false)
Expand All @@ -513,7 +513,7 @@ func (s *integrationSuite) TestQueryWorkflow_NonSticky() {
_, err = poller.PollAndProcessDecisionTask(false, false)
s.NoError(err)

go queryWorkflowFn(queryType, querypb.QUERY_REJECT_CONDITION_NONE)
go queryWorkflowFn(queryType, querypb.QUERY_REJECT_CONDITION_UNSPECIFIED)
// process that query task, which should respond via RespondQueryTaskCompleted
for {
// loop until process the query task
Expand Down Expand Up @@ -713,7 +713,7 @@ func (s *integrationSuite) TestQueryWorkflow_Consistent_PiggybackQuery() {

// call QueryWorkflow in separate goroutine (because it is blocking). That will generate a query task
// notice that the query comes after signal here but is consistent so it should reflect the state of the signal having been applied
go queryWorkflowFn(queryType, querypb.QUERY_REJECT_CONDITION_NONE)
go queryWorkflowFn(queryType, querypb.QUERY_REJECT_CONDITION_UNSPECIFIED)
// ensure query has had enough time to at least start before a decision task is polled
// if the decision task containing the signal is polled before query is started it will not impact
// correctness but it will mean query will be able to be dispatched directly after signal
Expand Down Expand Up @@ -891,7 +891,7 @@ func (s *integrationSuite) TestQueryWorkflow_Consistent_Timeout() {

// call QueryWorkflow in separate goroutine (because it is blocking). That will generate a query task
// notice that the query comes after signal here but is consistent so it should reflect the state of the signal having been applied
go queryWorkflowFn(queryType, querypb.QUERY_REJECT_CONDITION_NONE)
go queryWorkflowFn(queryType, querypb.QUERY_REJECT_CONDITION_UNSPECIFIED)
// ensure query has had enough time to at least start before a decision task is polled
// if the decision task containing the signal is polled before query is started it will not impact
// correctness but it will mean query will be able to be dispatched directly after signal
Expand Down Expand Up @@ -1059,7 +1059,7 @@ func (s *integrationSuite) TestQueryWorkflow_Consistent_BlockedByStarted_NonStic
// at the time the query comes in there will be a started decision task
// only once signal completes can queryWorkflow unblock
<-time.After(time.Second)
queryWorkflowFn(queryType, querypb.QUERY_REJECT_CONDITION_NONE)
queryWorkflowFn(queryType, querypb.QUERY_REJECT_CONDITION_UNSPECIFIED)
}()

_, err = poller.PollAndProcessDecisionTask(false, false)
Expand Down Expand Up @@ -1265,7 +1265,7 @@ func (s *integrationSuite) TestQueryWorkflow_Consistent_NewDecisionTask_Sticky()
})
s.NoError(err)

queryWorkflowFn(queryType, querypb.QUERY_REJECT_CONDITION_NONE)
queryWorkflowFn(queryType, querypb.QUERY_REJECT_CONDITION_UNSPECIFIED)
}()

_, err = poller.PollAndProcessDecisionTaskWithSticky(false, false)
Expand Down Expand Up @@ -1349,6 +1349,7 @@ func (s *integrationSuite) TestQueryWorkflow_BeforeFirstDecision() {
Query: &querypb.WorkflowQuery{
QueryType: queryType,
},
QueryConsistencyLevel: querypb.QUERY_CONSISTENCY_LEVEL_EVENTUAL,
})
s.IsType(&workflowservice.QueryWorkflowResponse{}, queryResp)
s.IsType(history.ErrQueryWorkflowBeforeFirstDecision, err)
Expand Down
Loading