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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
303181ec470063ef1e4ba11d15e1879ee8133434d0f133e8c8a80d3fbd71da87
|
|
| MD5 |
f9526279e9b138cb50a714d5576ef7cf
|
|
| BLAKE2b-256 |
41bfd17ed0a7b2d2e91bfed80c5ac53cb34bd1d67d5377ac029bcc3f727c0870
|
Provenance
The following attestation bundles were made for switchbox_openfeature-0.1.0.tar.gz:
Publisher:
publish-openfeature.yml on ignat14/switchbox-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
switchbox_openfeature-0.1.0.tar.gz -
Subject digest:
303181ec470063ef1e4ba11d15e1879ee8133434d0f133e8c8a80d3fbd71da87 - Sigstore transparency entry: 2155029267
- Sigstore integration time:
-
Permalink:
ignat14/switchbox-sdk-python@891b3f5e29810af555461e09512d776fd0bbac04 -
Branch / Tag:
refs/tags/openfeature-v0.1.0 - Owner: https://github.com/ignat14
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-openfeature.yml@891b3f5e29810af555461e09512d776fd0bbac04 -
Trigger Event:
push
-
Statement type:
File details
Details for the file switchbox_openfeature-0.1.0-py3-none-any.whl.
File metadata
- Download URL: switchbox_openfeature-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06a225fd9ec3871c07c891d0f6d4024da0707f13ca89011d1ada2a7fafbb9a1c
|
|
| MD5 |
370bcb1330c4becbca2d64e001619a7c
|
|
| BLAKE2b-256 |
15fef6a373baef5d9abb29dd9ae27d7583b388ab0b181c05ccc60d4a8903c8d8
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
switchbox_openfeature-0.1.0-py3-none-any.whl -
Subject digest:
06a225fd9ec3871c07c891d0f6d4024da0707f13ca89011d1ada2a7fafbb9a1c - Sigstore transparency entry: 2155029383
- Sigstore integration time:
-
Permalink:
ignat14/switchbox-sdk-python@891b3f5e29810af555461e09512d776fd0bbac04 -
Branch / Tag:
refs/tags/openfeature-v0.1.0 - Owner: https://github.com/ignat14
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-openfeature.yml@891b3f5e29810af555461e09512d776fd0bbac04 -
Trigger Event:
push
-
Statement type: