1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/src/lib
Thomas Heartman 85bd7845b0
#4205: mark potentially stale features (#4217)
This PR lays most of the groundwork required for emitting events when
features are marked as potentially stale by Unleash. It does **not**
emit any events just yet. The summary is:
- periodically look for features that are potentially stale and mark
them (set to run every 10 seconds for now; can be changed)
- when features are updated, if the update data contains changes to the
feature's type or createdAt date, also update the potentially stale
status.

It is currently about 220 lines of tests and about 100 lines of
application code (primarily db migration and two new methods on the
IFeatureToggleStore interface).

The reason I wanted to put this into a single PR (instead of just the db
migration, then just the potentially stale marking, then the update
logic) is:
If users get the db migration first, but not the rest of the update
logic until the events are fired, then they could get a bunch of new
events for features that should have been marked as potentially stale
several days/weeks/months ago. That seemed undesirable to me, so I
decided to bunch those changes together. Of course, I'd be happy to
break it into smaller parts.

## Rules

A toggle will be marked as potentially stale iff:
- it is not already stale
- its createdAt date is older than its feature type's expected lifetime
would dictate

## Migration

The migration adds a new `potentially_stale` column to the features
table and sets this to true for any toggles that have exceeded their
expected lifetime and that have not already been marked as `stale`.

## Discussion

### The `currentTime` parameter of `markPotentiallyStaleFeatures`

The `markPotentiallyStaleFetaures` method takes an optional
`currentTime` parameter. This was added to make it easier to test (so
you can test "into the future"), but it's not used in the application.
We can rewrite the tests to instead update feature toggles manually, but
that wouldn't test the actual marking method. Happy to discuss.
2023-07-13 12:02:33 +00:00
..
__snapshots__ feat: add slackAppAddon feature flag (#4235) 2023-07-13 12:26:22 +02:00
addons chore: Datadog addon, ability to include source type name (#4196) 2023-07-10 15:38:53 +02:00
db #4205: mark potentially stale features (#4217) 2023-07-13 12:02:33 +00:00
domain/project-health
error refactor: move status codes into classes (#4200) 2023-07-11 09:20:11 +02:00
features feat: feature creation limit crud together with frontend (#4221) 2023-07-13 14:02:35 +03:00
middleware fix: reduce severity of api token middleware errors (#4216) 2023-07-11 13:33:02 +03:00
openapi feat: strategy variant schema openapi (#4232) 2023-07-13 13:50:03 +02:00
proxy refactor: playground in feature oriented architecture (#3942) 2023-06-09 12:55:54 +02:00
routes openapi: document operations for admin ui feedback (#4226) 2023-07-13 13:27:52 +02:00
schema chore: deprecate username on api-tokens (#3616) 2023-05-04 09:56:00 +02:00
segments chore: add additional methods we want exposed (#3771) 2023-05-15 10:23:28 +00:00
services #4205: mark potentially stale features (#4217) 2023-07-13 12:02:33 +00:00
types #4205: mark potentially stale features (#4217) 2023-07-13 12:02:33 +00:00
util fix: correct escaping of ui flags for plausible (#3907) 2023-07-07 17:40:37 +02:00
app.test.ts
app.ts fix: remove consecutive slashes (#3882) 2023-05-27 16:16:51 +00:00
create-config.test.ts chore: remove optimal 304 flag (#3665) 2023-05-05 09:18:04 +02:00
create-config.ts fix: SERVER_KEEPALIVE_TIMEOUT env variable should be seconds (#4130) 2023-07-03 09:35:02 +02:00
default-custom-auth-deny-all.ts
internals.ts chore: drop event hook (#3565) 2023-04-21 09:44:18 +02:00
logger.test.ts
logger.ts
metric-events.ts
metrics.test.ts chore: add linter rules for regexp (#3500) 2023-04-17 07:11:22 +00:00
metrics.ts Poc: calculate etag based on query and latest revison id (#3062) 2023-03-17 14:10:21 +01:00
server-impl.test.ts chore: drop event hook (#3565) 2023-04-21 09:44:18 +02:00
server-impl.ts chore: set unleash version to be either the enterprise version or OSS (#3974) 2023-06-13 19:39:49 +02:00