open-feature/java-sdk

How to batch-load flags?

Closed this issue · 1 comments

Let's say you need a couple of feature flags in your application logic. Is there currently any recommended approach to batch-load those flags? As far as i understand with the current spec, you need to load them one by one. Meaning if you load them form a backend via http for example, n http requests for n flags to be evaluated?

The flag evaluation API exposed to application authors only allows one flag to be evaluated at a time, but that doesn't prevent the provider (which is actually responsible for evaluating the flags) from doing some kind of bulk evaluation ahead of time.

Some providers pull a "rules engine" that is used to evaluate flags entirely locally. Some cache flags for a particular context, or do some kind of bulk evaluation for each context. Every provider does this differently, but most do something like this to prevent the kind of chatter you are describing.

This is especially true for the client side use-case. In this use-case, we use the "static paradigm" where the context is only changed periodically. When that happens, the provider's onContextChanged handler is run, which is a great place to do a bulk flag evaluation for that context. See JS doc for the web-sdk and draft spec.