-
Notifications
You must be signed in to change notification settings - Fork 911
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
Use new API's simpler representation of versioning data #3432
Use new API's simpler representation of versioning data #3432
Conversation
2d201a1
to
de0fe81
Compare
8614b5e
to
f6bb789
Compare
f6bb789
to
f264d93
Compare
if data == nil || data.GetVersionSets() == nil { | ||
return nil | ||
} | ||
asBytes, err := data.Marshal() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is technically not guaranteed to be deterministic. I'm not sure how much we care
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems kinda important. Can I use these XXX_Marshall functions? Gogo proto's docs are less than clear. Or is there some other simple way to guarantee that without doing it all by hand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if there's anything in the proto lib or generated code that guarantees it. But I think in practice we can rely on it being deterministic within a single binary (running on a single architecture), which is the situation we care about
service/matching/version_sets.go
Outdated
} | ||
sets := g.GetVersionSets() | ||
startIndex := len(sets) - maxDepth | ||
shortened := g.GetVersionSets()[startIndex:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shortened := g.GetVersionSets()[startIndex:] | |
shortened := util.SliceTail(g.GetVersionSets(), maxDepth) |
(package common/util
)
or really maybe just inline this at the two sites? one function that does two kinda related but different things is a little icky
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used the util, but kept this. I just can't bring myself to copy-paste stuff lol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed this anyways since the linter whines about it
service/matching/version_sets.go
Outdated
} | ||
|
||
existingData.VersionSets = append(existingData.GetVersionSets(), &taskqueuepb.CompatibleVersionSet{ | ||
Versions: []string{targetedVersion}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to generate a uuid here. I have it in my pending PR on top of this but you could add it here if you want
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
service/matching/version_sets.go
Outdated
} | ||
|
||
func extractTargetedVersion(req *workflowservice.UpdateWorkerBuildIdCompatabilityRequest) string { | ||
if req.GetAddNewCompatibleVersion() != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kinda weird to effectively do this type switch twice, and using a different technique too. I know go (nor proto) doesn't have the pattern matching that would make this nice, but maybe better to do one switch and just pull these out of the typed value? (i.e. drop this function entirely and just read the fields as required in the function above)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem is I also need to get it out first to pass it into findVersion
. I've made the styles consistent now but I don't immediately see a non-super-duplicative way to get rid of this fn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I meant duplicate calls to findVersion in each branch. it's more duplication in some ways (code in branches of type switch) and less in others (type switch itself). overall I'm guessing it comes out shorter. but it's subjective so 🤷
deaaf56
to
0087277
Compare
Will be merged after API/Go sdk changes |
3830d5f
to
dae80d0
Compare
dae80d0
to
27ca14f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just stylistic stuff at this point so feel free to take the suggestions you like
@@ -44,8 +44,8 @@ require ( | |||
go.opentelemetry.io/otel/metric v0.36.0 | |||
go.opentelemetry.io/otel/sdk v1.13.0 | |||
go.opentelemetry.io/otel/sdk/metric v0.36.0 | |||
go.temporal.io/api v1.18.1 | |||
go.temporal.io/sdk v1.21.1 | |||
go.temporal.io/api v1.19.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the future I don't think there's any reason to "release" the api repo, we can just use whatever commit
if data == nil || data.GetVersionSets() == nil { | ||
return nil | ||
} | ||
asBytes, err := data.Marshal() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if there's anything in the proto lib or generated code that guarantees it. But I think in practice we can rely on it being deterministic within a single binary (running on a single architecture), which is the situation we care about
} | ||
// Limit graph size if it's grown too large | ||
newResp := depthLimiter(existingData, maxSize) | ||
existingData.VersionSets = newResp.GetMajorVersionSets() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creating a "response" struct in the function to just pull out one field is one reason I wanted to inline this. I still think that would be better, but it's subjective at this point
|
||
// Finds the version in the version sets, returning (set index, index within that set) | ||
// Returns -1, -1 if not found. | ||
func findVersion(data *persistence.VersioningData, buildID string) findVersionRes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use multiple return values instead of struct?
func findVersion(data *persistence.VersioningData, buildID string) findVersionRes { | |
func findVersion(data *persistence.VersioningData, buildID string) (setIndex int, indexInSet int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The linter bitched at me for that lol
service/matching/version_sets.go
Outdated
} | ||
|
||
func extractTargetedVersion(req *workflowservice.UpdateWorkerBuildIdCompatabilityRequest) string { | ||
if req.GetAddNewCompatibleVersion() != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I meant duplicate calls to findVersion in each branch. it's more duplication in some ways (code in branches of type switch) and less in others (type switch itself). overall I'm guessing it comes out shorter. but it's subjective so 🤷
What changed?
Handle changes in temporalio/api#237 which simplify the graph representation. Draft until that is merged (and sdk-go, etc).
Why?
Simpler better
How did you test it?
Changed all existing tests which still made sense, dropped nonsense ones, added new ones.
Potential risks
None, not in use yet.
Is hotfix candidate?