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

Drop pointers for domain name/id fields #3916

Conversation

vytautas-karpavicius
Copy link
Contributor

What changed?
Drop pointers for domain name/id fields within internal types. This is mostly mechanical change touching only those fields which are always required. This removes common.StringPtr helpers everywhere and modifies checks for empty domain instead of nil in handler validation. This is equivalent to previous logic, because incoming nil from request was masked everywhere with GetDomain helper, which returned empty string anyway. Now this is done at the mapping layer.

There were a few cases were domain id could be optional. In particular:

  • ParentExecutionInfo.DomainUUID / ParentExecutionInfo.Domain
  • WorkflowExecutionInfo.ParentDomainID
  • WorkflowExecutionStartedEventAttributes.ParentWorkflowDomain
  • ActivityTaskScheduledEventAttributes.Domain
    In those cases there were additional logic attached to != nil case. I will check if it makes sense to use zero value for those and address that in a separate PR later if needed.

Why?
This is one of PRs planned to drop pointers for always required fields in internal types. It will make them more idiomatic and easier to use. These pointer are legacy of Thrift types that were used previously through our codebase. This will also allow safer migration to grpc, as proto primitive types don't have nils by default.

How did you test it?
Passing build and existing tests.

Potential risks

@coveralls
Copy link

coveralls commented Jan 22, 2021

Coverage Status

Coverage decreased (-0.03%) to 61.695% when pulling aa3f881 on vytautas-karpavicius:drop-ptr-domain into 88e1b65 on uber:master.

@vytautas-karpavicius vytautas-karpavicius marked this pull request as ready for review January 22, 2021 14:26
Comment on lines 3157 to +3160
// send a signal on third failure to be buffered, forcing a non-transient decision when buffer is flushed
/*if failureCount == 3 {
err := s.engine.SignalWorkflowExecution(createContext(), &types.SignalWorkflowExecutionRequest{
Domain: common.StringPtr(s.domainName),
Domain: s.domainName,
Copy link
Member

Choose a reason for hiding this comment

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

commented out?

not relevant for this diff, but is this something we should restore?

@@ -470,7 +470,7 @@ func (t *taskAckManagerImpl) generateFailoverMarkerTask(
TaskType: types.ReplicationTaskType.Ptr(types.ReplicationTaskTypeFailoverMarker),
SourceTaskID: common.Int64Ptr(taskInfo.GetTaskID()),
FailoverMarkerAttributes: &types.FailoverMarkerAttributes{
DomainID: common.StringPtr(taskInfo.GetDomainID()),
Copy link
Member

Choose a reason for hiding this comment

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

some of these original lines are a bit facepalm-ridden :|
e.g. this one takes a nullable *string, converts it to a non-null string defaulting to "", then gets a pointer back to *string. effectively just forgetting if the original was null or not.

well. this is why I like this PR, I suppose.

Copy link
Member

@Groxx Groxx left a comment

Choose a reason for hiding this comment

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

(same as on wid/rid PR)

Well. The nullable pointer -> non-null pointer changes in the mappers are quite hard to trace and verify... so I'm not sure what can be done beyond "yolo, test it in prod". or spend an incredible amount of time trying to verify it all.

wid/rid/domain all seem pretty likely to always be present where required, so odds of this working are pretty good I think. works for me 👍

@vytautas-karpavicius vytautas-karpavicius merged commit 2847890 into cadence-workflow:master Jan 26, 2021
github-actions bot pushed a commit to vytautas-karpavicius/cadence that referenced this pull request Feb 4, 2021
yux0 pushed a commit to yux0/cadence that referenced this pull request May 4, 2021
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.

4 participants