Skip to content

Server SDKs resilient to network/http errors #307

@devnev

Description

@devnev

For my use-case, I would like to avoid having Flipt on the critical path to request handling, i.e. high latency or errors from Flipt should not fail a request. This can already be accomplished, but in some languages it requires awareness and a bunch of surrounding code at every location where flipt is invoked.

e.g. its OK in Rust:

if (flipt.evaluation.boolean(...).await.unwrap()) { ... } // unwrap makes potential panic clear, and can easily be replaced with:
if (flipt.evaluation.boolean(...).await.map_or(true, |r| r.enabled)) { ... }

but in PHP, its easy to miss, and noisy to fix:

if ($flipt->boolean(...)->getEnabled()) { ... } // request failures not handled, easily missed
// vs
try {
  $enabled = $flipt->boolean(...)->getEnabled();
} catch (\Psr\Http\Client\RequestException $e) {
  $enabled = true;
}
if ($enabled) { ... }

So I'm wondering if SDKs where this is relevant could include aids to make callers of flipt more resilient.

I can imagine a few approaches:

  • Flipt clients have additional evaluation methods that take a fallback value: the simplest, but also doesn't make it visible when a developer forgets to call the method with a fallback
  • Separate client interface where all methods require fallback values: odd duplication of the client, you the non-resilient method can't accidentally be called on the resilient client. Of course, that still requires that the right client be instantiated, but client instantiation ideally happens in just one or two places in the program, not at every evaluation site, making them easier to vet.
  • Give the client an option for producing fallback values in case of exceptions. Leaves the callers and general usage unchanged, but it implies every flag evaluation can take the same fallback value, which seems questionable for booleans and infeasible for variants.
  • Leave it as is, users with this need have to wrap the client themselves, and be more susceptable to flipt errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions