-
-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We are changing how the Delta API works, as discussed: 1. We have removed the `updated` and `removed` arrays and now keep everything in the `events` array. 2. We decided to keep the hydration cache separate from the events array internally. Since the hydration cache has a special structure and may contain not just one feature but potentially 1,000 features, it behaved differently, requiring a lot of special logic to handle it. 3. Implemented `nameprefix` filtering, which we were missing before. Things still to implement: 1. Segment hydration and updates to it.
- Loading branch information
Showing
12 changed files
with
659 additions
and
469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/lib/features/client-feature-toggles/delta/client-feature-toggle-delta-types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import type { ClientFeatureSchema } from '../../../openapi'; | ||
import type { IClientSegment } from '../../../types'; | ||
|
||
export type DeltaHydrationEvent = { | ||
eventId: number; | ||
type: 'hydration'; | ||
features: ClientFeatureSchema[]; | ||
}; | ||
|
||
export type DeltaEvent = | ||
| { | ||
eventId: number; | ||
type: 'feature-updated'; | ||
feature: ClientFeatureSchema; | ||
} | ||
| { | ||
eventId: number; | ||
type: 'feature-removed'; | ||
featureName: string; | ||
project: string; | ||
} | ||
| { | ||
eventId: number; | ||
type: 'segment-updated'; | ||
segment: IClientSegment; | ||
} | ||
| { | ||
eventId: number; | ||
type: 'segment-removed'; | ||
segmentId: number; | ||
}; | ||
|
||
export const DELTA_EVENT_TYPES = { | ||
FEATURE_UPDATED: 'feature-updated', | ||
FEATURE_REMOVED: 'feature-removed', | ||
SEGMENT_UPDATED: 'segment-updated', | ||
SEGMENT_REMOVED: 'segment-removed', | ||
HYDRATION: 'hydration', | ||
} as const; | ||
|
||
export const isDeltaFeatureUpdatedEvent = ( | ||
event: DeltaEvent, | ||
): event is Extract<DeltaEvent, { type: 'feature-updated' }> => { | ||
return event.type === DELTA_EVENT_TYPES.FEATURE_UPDATED; | ||
}; | ||
|
||
export const isDeltaFeatureRemovedEvent = ( | ||
event: DeltaEvent, | ||
): event is Extract<DeltaEvent, { type: 'feature-removed' }> => { | ||
return event.type === DELTA_EVENT_TYPES.FEATURE_REMOVED; | ||
}; | ||
|
||
export const isDeltaSegmentUpdatedEvent = ( | ||
event: DeltaEvent, | ||
): event is Extract<DeltaEvent, { type: 'segment-updated' }> => { | ||
return event.type === DELTA_EVENT_TYPES.SEGMENT_UPDATED; | ||
}; | ||
|
||
export const isDeltaSegmentRemovedEvent = ( | ||
event: DeltaEvent, | ||
): event is Extract<DeltaEvent, { type: 'segment-removed' }> => { | ||
return event.type === DELTA_EVENT_TYPES.SEGMENT_REMOVED; | ||
}; |
Oops, something went wrong.