-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
VAULT-14733: Split logic of precomputedQueryWorker #20073
Conversation
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 another dramatic improvement. Looks great! I threw in some initial superficial review comments regarding the method signatures. I'm going to do another pass on this with more impactful feedback, but just wanted to get the conversation started on a couple of things.
|
||
// pqOptions holds fields that will be used when creating precomputed queries | ||
// These fields will remain the same for every segment that a precomputed query worker is handling | ||
type pqOptions struct { |
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 terrific!
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.
Nit-heavy review. I threw in a bunch of items around clarity/comment usefulness that I think could help. There's also one reverse-logic item that I'd like to see addressed.
vault/activity_log.go
Outdated
// reverse ordering). If yes, we remove those references. This way a | ||
// client is considered new only in the earliest month of its use in | ||
// the billing period. | ||
for currMonth := timeutil.StartOfMonth(segmentTime).UTC(); currMonth != timeutil.StartOfMonth(opts.activePeriodEnd).UTC(); currMonth = timeutil.StartOfNextMonth(currMonth).UTC() { |
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 seems like it could maybe be abstracted out into a rangeMonths
method in timeutil
, especially if it's used elsewhere (I haven't looked).
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.
Barring that approach, I think capturing lastMonth := timeutil.StartOfMonth(opts.activePeriodEnd).UTC()
outside of this loop and just using that variable in a currMonth.Before(lastMonth)
could be useful.
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 only used in one place, so i didn't make a new method in timeutil. I did clean it up according to your suggestion.
a.logger.Warn("failed to read segment", "error", err) | ||
return err | ||
} | ||
err = a.handleEntitySegment(entity, segmentTime, hyperloglog, opts) |
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 wish there was a way for us to avoid 3 levels of nested for loops, but I suppose there's a lot going on here, so it's kind of unavoidable.
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.
😢
d51cd82
to
0625e2f
Compare
This PR splits up the precomputed query worker so that the logic transforming a segment to a precomputed query sits in its own method. This method will later be used by the client count generation endpoint.