Flipt Client Evaluation SDK
Project description
Flipt Client Python
The flipt-client-python
library contains the Python source code for the Flipt client-side evaluation client.
Installation
pip install flipt-client
How Does It Work?
The flipt-client-python
library is a wrapper around the flipt-engine-ffi library.
All evaluation happens within the SDK, using the shared library built from the flipt-engine-ffi library.
Because the evaluation happens within the SDK, the SDKs can be used in environments where the Flipt server is not available or reachable after the initial data is fetched.
Data Fetching
Upon instantiation, the flipt-client-python
library will fetch the flag state from the Flipt server and store it in memory. This means that the first time you use the SDK, it will make a request to the Flipt server.
Polling (Default)
By default, the SDK will poll the Flipt server for new flag state at a regular interval. This interval can be configured using the update_interval
option when constructing a client. The default interval is 120 seconds.
Streaming (Flipt Cloud Only)
Flipt Cloud users can use the streaming
fetch method to stream flag state changes from the Flipt server to the SDK.
When in streaming mode, the SDK will connect to the Flipt server and open a persistent connection that will remain open until the client is closed. The SDK will then receive flag state changes in real-time.
Supported Architectures
This SDK currently supports the following OSes/architectures:
- Linux x86_64
- Linux arm64
- MacOS x86_64
- MacOS arm64
- Windows x86_64
Usage
In your Python code you can import this client and use it as so:
from flipt_client import FliptEvaluationClient
# "namespace" and "options" are two keyword arguments that this constructor accepts
# namespace: which namespace to fetch flag state from
# options: follows the model ClientOptions in the models.py file. Configures the url of the upstream Flipt instance, the interval in which to fetch new flag state, and the authentication method if your upstream Flipt instance requires it
flipt_evaluation_client = FliptEvaluationClient()
variant_result = flipt_evaluation_client.evaluate_variant(flag_key="flag1", entity_id="entity", context={"fizz": "buzz"})
print(variant_result)
Constructor Arguments
The FliptEvaluationClient
constructor accepts two optional arguments:
namespace
: The namespace to fetch flag state from. If not provided, the client will default to thedefault
namespace.options
: An instance of theClientOptions
class that supports several options for the client. The structure is:url
: The URL of the upstream Flipt instance. If not provided, the client will default tohttp://localhost:8080
.update_interval
: The interval (in seconds) in which to fetch new flag state. If not provided, the client will default to 120 seconds.authentication
: The authentication strategy to use when communicating with the upstream Flipt instance. If not provided, the client will default to no authentication. See the Authentication section for more information.reference
: The reference to use when fetching flag state. If not provided, reference will not be used.fetch_mode
: The fetch mode to use when fetching flag state. If not provided, the client will default to polling.
Authentication
The FliptEvaluationClient
supports the following authentication strategies:
- No Authentication (default)
- Client Token Authentication
- JWT Authentication
Contributing
Contributions are welcome! Please feel free to open an issue or submit a Pull Request.
License
This project is licensed under the MIT License.
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
File details
Details for the file flipt_client-0.12.0.tar.gz
.
File metadata
- Download URL: flipt_client-0.12.0.tar.gz
- Upload date:
- Size: 19.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.0 CPython/3.11.10 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21df7bddd413191f39bfe68544bcbd33b1fa858869d48f14e35f869a16ee2efb |
|
MD5 | 2d5ebea40ccc481e249fd88f57027d96 |
|
BLAKE2b-256 | b944ad56b02677e74ac67e9f057ea8503874a19ea4dd55585e5eda67d2b38654 |
File details
Details for the file flipt_client-0.12.0-py3-none-any.whl
.
File metadata
- Download URL: flipt_client-0.12.0-py3-none-any.whl
- Upload date:
- Size: 20.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.0 CPython/3.11.10 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dd707ab5266eb8243b8283742a3ba11cea85c526ca03bee1a5d14df80afac79 |
|
MD5 | 0a971d544485b65b10259055dfc1c530 |
|
BLAKE2b-256 | 481af531c3df6ee1d8f80b4165ee06042a2fc889beed2d15c0ede119d8f642f0 |