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

Conversation

alexshtin
Copy link
Member

What changed?
UNSPECIFIED value was added to every enum as 0 item.

Why?
To follow protobuf style guide and to be compatible with buf linter.

How did you test it?
Run all tests.

Potential risks
There is a risk that some default values are not set correctly and UNSPECIFIED value can go through the code and stored in DB.

@alexshtin alexshtin requested review from samarabbas, shawnhathaway and a team June 10, 2020 05:51
// 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

}

enum TaskCategory {
TASK_CATEGORY_UNSPECIFIED = 0;
// Transfer is the task type for transfer task
TASK_CATEGORY_TRANSFER = 2; // starting from 2 here to be consistent with the row type define for cassandra
Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't able to figure out why it started with 2 and reset it to normal 1.

@@ -205,7 +205,7 @@ func (r *mutableStateTaskGeneratorImpl) generateDelayedDecisionTasks(
commonpb.CONTINUE_AS_NEW_INITIATOR_DECIDER:
firstDecisionDelayType = persistence.WorkflowBackoffTimeoutTypeCron
default:
return serviceerror.NewInternal(fmt.Sprintf("unknown iterator retry policy: %v", startAttr.GetInitiator()))
Copy link
Member Author

Choose a reason for hiding this comment

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

🤦

@@ -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.

👯

// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package enums
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

@@ -1332,7 +1332,7 @@ func getWorkflowStatus(statusStr string) executionpb.WorkflowExecutionStatus {
}

func getWorkflowIDReusePolicy(value int) commonpb.WorkflowIdReusePolicy {
if value >= 0 && value <= len(commonpb.WorkflowIdReusePolicy_value) {
if value > 0 && value < len(commonpb.WorkflowIdReusePolicy_value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Gah, we force customers to pass integer here - WIll log issue


func SetDefaultQueryConsistencyLevel(f *querypb.QueryConsistencyLevel){
if *f == querypb.QUERY_CONSISTENCY_LEVEL_UNSPECIFIED{
*f = querypb.QUERY_CONSISTENCY_LEVEL_EVENTUAL
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think eventual consistency should be the default here. We should default to new implementation which is highly consistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mfateev what's your take?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am setting this to STRONG for now, but Max suggested to remove this field completely from request. I will do it as separate PR.


func SetDefaultTasklListType(f *tasklistpb.TaskListType){
if *f == tasklistpb.TASK_LIST_TYPE_UNSPECIFIED{
*f = tasklistpb.TASK_LIST_TYPE_DECISION
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need a default here. This should be a required option. What is the use case when this is optional?

Copy link
Member Author

@alexshtin alexshtin Jun 11, 2020

Choose a reason for hiding this comment

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

Made it required for DescribeTaskList.

// Replication is the task type for replication task
TASK_CATEGORY_REPLICATION = 4;
// Transfer is the task type for transfer task.
TASK_CATEGORY_TRANSFER = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure where this enum is getting used but It might become an issue if this is used as row with history shard. If that is the case then we use the value '1' to represent shard info within the same partition.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is an enum:

const (
	// Row types for table executions
	rowTypeShard = iota
	rowTypeExecution
	rowTypeTransferTask
	rowTypeTimerTask
	rowTypeReplicationTask
	rowTypeDLQ
)

There is shard info but it has value 0. And this proto enum doesn't intersect with go enum above in a code.

}

func SetDefaultTasklListKind(f *tasklistpb.TaskListKind){
if *f == tasklistpb.TASK_LIST_KIND_UNSPECIFIED{
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this public API? I'm surprised if it is as client never cares about tasklist kind. If this is internal then we should make it required.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it is used in DescribeTaskList and actually validated everywhere where TaskList is a part of request. Left it optional and set it to NORMAL if not set on request.

@alexshtin alexshtin merged commit fe378c0 into temporalio:master Jun 11, 2020
@alexshtin alexshtin deleted the feature/enum-unspecified branch June 11, 2020 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants