Expose upcoming scheduled changes in the environment document, so local-evaluation SDKs can flip flags exactly at live_from

Ouverte
#7,973 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
35/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
Calme
Stack technique
python

Piste de recherche

Commencez par l’endpoint du document d’environnement et suivez le mapper côté serveur qui assemble les états des fonctionnalités. Examinez la représentation des lignes directes futures de FeatureState/version et des change-sets planifiés en attente, puis inspectez les tests associés de l’endpoint s’ils existent. C’est terminé lorsque la réponse d’opt-in n’expose que la modification future la plus proche pour chaque état de fonctionnalité concerné, tout en conservant la réponse existante lorsque le paramètre est absent.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Is your feature request related to a problem?

When a change is scheduled via a future live_from, Flagsmith's server correctly promotes it to the "live" value once that time passes — but SDKs running in local evaluation mode (fetch the environment document once, cache it, evaluate flags in-process for low latency) only see that promotion on their next document poll strictly after live_from. With the default/typical refresh intervals many teams configure (often well beyond the default 60s to reduce API load), this means the actual observed flip time is live_from + up to one full refresh interval, and there's no way for the SDK to know in advance that a change is coming. The only current workarounds are polling much more frequently around the scheduled time (which the SDK can't do, since it doesn't know a schedule exists) or falling back to remote evaluation for that flag (which defeats the purpose of local evaluation).

Describe the solution you'd like

Add an opt-in query parameter (e.g. include_scheduled=true) to the environment document endpoint that, when present, attaches the single nearest not-yet-live future value to each affected feature state: scheduled_change: { live_from, enabled, feature_state_value }. Local-evaluation SDKs can then cheaply compare now() against the cached live_from on every flag-resolution call and start serving the scheduled value once it's reached — without waiting for or requiring a new document fetch. The field is omitted entirely when not requested, so existing SDKs and cached documents stay byte-for-byte unaffected (fully backward compatible, opt-in only).

We've prototyped this end-to-end: a server-side mapper change that merges scheduling information from both direct future FeatureState/version rows and pending scheduled change-sets (with an "earliest wins" rule when more than one candidate exists), plus a client-side implementation in flagsmith-java-client (a small model class with an isLive() check, applied at every flag-resolution entry point) and a corresponding option in the OpenFeature Java provider. In testing, a flag scheduled ~45s in the future correctly stayed at its old value right up to live_from, then flipped at live_from on an already-running client with zero new document fetches (refresh interval set far longer than the test window to isolate this from ordinary polling).

A notable side benefit: because every instance in a fleet independently prefetches the same scheduled_change (via its normal, already-staggered polling), and each one resolves maturity locally from its own clock rather than from when it happened to poll, all instances flip to the new value at essentially the same moment — bounded only by clock skew across the fleet, not by how staggered their poll timings are. Without this mechanism, instances that poll on independent/staggered schedules would pick up a promoted value at different times (each up to one refresh interval after live_from, and out of sync with each other by up to that same interval). This gives multi-instance deployments millisecond-level synchronized flag flips "for free," without needing a dedicated distributed-coordination mechanism (leader election, distributed lock, message bus, etc.) just to make a scheduled change take effect consistently across a fleet at the same instant.

Describe alternatives you've considered
  • Poll more frequently as the scheduled time approaches — requires the SDK to already know a change is coming, which is the problem being solved, and increases load if applied broadly rather than narrowly.
  • Push-based invalidation (webhook/SSE telling clients to refetch) — heavier infrastructure requirement, and most server-side SDKs in local-evaluation mode don't have an inbound channel to receive it; also doesn't remove the "refetch round trip" latency itself.
  • Rely on remote evaluation for anything scheduled — works, but forces giving up local evaluation's low-latency, no-per-request-round-trip benefit specifically for flags that use scheduling.
Additional context

Known simplification in the prototype: only the single nearest upcoming change per feature state is exposed, not a full list of all pending future changes — intentional, since in Flagsmith's version-chain model only one transition is ever actionable at a time (the next one becomes visible on the following poll once the current one matures). Willing to share more implementation detail or open a draft PR to flagsmith-java-client (and discuss the OpenFeature provider separately) once maintainers confirm interest in the server-side API shape.

Langage dominant
Python
Étoiles
9.9k
Forks
658
Merge moyen
1 j 15 h
PR mergées (30 j)
168

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de Flagsmith/flagsmith

Toutes les issues de Flagsmith/flagsmith

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.