-
-
Notifications
You must be signed in to change notification settings - Fork 740
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
feat: delta rework #9133
feat: delta rework #9133
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
@sjaanus, core features have been modified in this pull request. Please review carefully! |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files |
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.
Some feedback we'll need to address before merging. I might just be missing context but let's discuss it before we go ahead.
if (delta?.events[0].type === 'hydration') { | ||
const hydrationEvent: DeltaHydrationEvent = | ||
delta?.events[0]; | ||
const sortedNewToggles = hydrationEvent.features.sort( | ||
(a, b) => a.name.localeCompare(b.name), | ||
); | ||
|
||
if ( | ||
!this.deepEqualIgnoreOrder(sortedToggles, sortedNewToggles) | ||
) { | ||
this.logger.warn( | ||
`old features and new features are different. Old count ${ | ||
features.length | ||
}, new count ${delta?.updated.length}, query ${JSON.stringify(query)}, | ||
if ( | ||
!this.deepEqualIgnoreOrder( | ||
sortedToggles, | ||
sortedNewToggles, | ||
) | ||
) { | ||
this.logger.warn( | ||
`old features and new features are different. Old count ${ | ||
features.length | ||
}, new count ${hydrationEvent.features.length}, query ${JSON.stringify(query)}, | ||
diff ${JSON.stringify( | ||
diff(sortedToggles, sortedNewToggles), | ||
)}`, | ||
); | ||
} | ||
} else { | ||
this.logger.warn( | ||
`Delta diff should have only hydration event, query ${JSON.stringify(query)}`, |
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.
Is this the correct implementation of the diff checker? If we only compare on hydration event, how do we know that the deltas are producing the correct result?
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.
Well, every time you add new events to cache, they will instantly applied to hydration event.
We only take features from database at first, but after that we will start manipulation the hydration event every second by applying the deltas.
@@ -0,0 +1,63 @@ | |||
import type { ClientFeatureSchema } from '../../../openapi'; |
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.
Love this file. Very clean.
(isDeltaFeatureUpdatedEvent(revision) && | ||
revision.feature.name.startsWith(namePrefix)) || | ||
(isDeltaFeatureRemovedEvent(revision) && | ||
revision.featureName.startsWith(namePrefix)) |
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.
Why are these different?
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.
Feature updated has complex object of feature, with all the description, strategies, constraints. Removed has just string value.
return ( | ||
startsWithPrefix(revision) && (allProjects || isInProject(revision)) | ||
); |
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.
We always filter with namePrefix? What if nameprefix is empty?
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.
if (requiredRevisionId >= this.currentRevisionId) { | ||
return undefined; | ||
} | ||
if (requiredRevisionId === 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.
Might be missing some context, but if this is the revisionId coming from the SDK, couldn't it possibly be undefined? Why a strict check on 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.
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.
LGTM
We are changing how the Delta API works, as discussed:
updated
andremoved
arrays and now keep everything in theevents
array.nameprefix
filtering, which we were missing before.Things still to implement: