Skip to main content

OpenFeature provider for Switchbox feature flags

Project description

switchbox-openfeature

OpenFeature provider for Switchbox feature flags.

What is this?

A thin provider that plugs Switchbox into the vendor-neutral OpenFeature API. Your app codes against OpenFeature; Switchbox is one constructor line. Swap vendors by swapping the provider, not your call sites. That is the point: no lock-in.

The provider contains zero evaluation logic. It wraps switchbox-flags, which fetches static JSON from a CDN and evaluates rules locally in your process. Nothing about the architecture changes: same 30 second polling, same local evaluation, same deterministic rollouts. Every resolve is a direct in-process call, so evaluation costs zero network.

Install

pip install switchbox-openfeature

This pulls in openfeature-sdk and switchbox-flags.

Quick Start

from openfeature import api
from openfeature.evaluation_context import EvaluationContext
from switchbox_openfeature import SwitchboxProvider

api.set_provider(SwitchboxProvider(sdk_key="your-sdk-key-from-dashboard"))
client = api.get_client()

context = EvaluationContext(targeting_key="user-42", attributes={"plan": "pro"})

if client.get_boolean_value("new_checkout", False, context):
    show_new_checkout()

SwitchboxProvider(...) accepts every Switchbox constructor option (poll_interval, cdn_base_url, on_error, ...). To share a client you already manage, pass it instead; the provider will not close it:

provider = SwitchboxProvider(client=my_switchbox)

Context mapping

OpenFeature's evaluation context maps onto the Switchbox user context:

OpenFeature Switchbox
targeting_key user_id (deterministic rollout bucketing)
every other attribute targeting attribute, passed through as-is

Error behavior

  • Missing flag: OpenFeature returns your code default with FLAG_NOT_FOUND
  • Evaluated value has the wrong type: code default with TYPE_MISMATCH
  • CDN unreachable at startup: the provider reports not-ready and OpenFeature serves code defaults (the same fail-safe posture as the SDK itself)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

switchbox_openfeature-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

switchbox_openfeature-0.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file switchbox_openfeature-0.1.0.tar.gz.

File metadata

  • Download URL: switchbox_openfeature-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for switchbox_openfeature-0.1.0.tar.gz
Algorithm Hash digest
SHA256 303181ec470063ef1e4ba11d15e1879ee8133434d0f133e8c8a80d3fbd71da87
MD5 f9526279e9b138cb50a714d5576ef7cf
BLAKE2b-256 41bfd17ed0a7b2d2e91bfed80c5ac53cb34bd1d67d5377ac029bcc3f727c0870

See more details on using hashes here.

Provenance

The following attestation bundles were made for switchbox_openfeature-0.1.0.tar.gz:

Publisher: publish-openfeature.yml on ignat14/switchbox-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file switchbox_openfeature-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for switchbox_openfeature-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06a225fd9ec3871c07c891d0f6d4024da0707f13ca89011d1ada2a7fafbb9a1c
MD5 370bcb1330c4becbca2d64e001619a7c
BLAKE2b-256 15fef6a373baef5d9abb29dd9ae27d7583b388ab0b181c05ccc60d4a8903c8d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for switchbox_openfeature-0.1.0-py3-none-any.whl:

Publisher: publish-openfeature.yml on ignat14/switchbox-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page