A tiny feature toggle module.
Project description
TinyToggle
TinyToggle is a lightweight, dependency-free Python module for implementing feature toggles (also known as feature flags) in your applications. It allows you to easily integrate your own flag evaluation functions, supporting various use cases such as load balancing, named features, and more.
Features
- Lightweight and dependency-free (uses only Python built-ins)
- Flexible: bring your own flag evaluation function
- Easy to use and integrate into existing projects
- Supports multiple flag types (strings, booleans, etc.)
- Provides a default implementation option
Installation
You can install TinyToggle using pip:
pip install tinytoggle
Usage
Here's a basic example of how to use TinyToggle:
from tinytoggle import TinyToggle
# Define your flag evaluation function
def get_flag_value(parameter):
# Your logic to retrieve the flag value
return "blue"
# Create a TinyToggle instance
my_feature = TinyToggle(get_flag_value)
# Define implementations for different flag values
@my_feature.flag("blue")
def blue_implementation():
print("Blue implementation")
@my_feature.flag("green")
def green_implementation():
print("Green implementation")
@my_feature.default
def default_implementation():
print("Default implementation")
# Use the feature
my_feature() # This will call the appropriate implementation based on the flag value
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Upcoming Features
- Add logging with JSON export of statistics
- Implement simple load balancer
- Add tests
Acknowledgements
Thanks to all the contributors who have helped to improve TinyToggle.
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 tinytoggle-2024.7.3.tar.gz.
File metadata
- Download URL: tinytoggle-2024.7.3.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73c6a6a6e7ab0f415f6214eee27bd131469d59d11fc0535218a822785e2957a4
|
|
| MD5 |
b5d629d47d84557dc7cd7073a72562f5
|
|
| BLAKE2b-256 |
bcaa70b8e8cf3005c72923830c8f244059e72b83bb12369c2660e46a8c73eef3
|
File details
Details for the file tinytoggle-2024.7.3-py3-none-any.whl.
File metadata
- Download URL: tinytoggle-2024.7.3-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e07bd311ca7c2913593419bc6d9a190225999f03ed6a87eebcf2e574a0a7576
|
|
| MD5 |
586a4f4c74a32d6845a590581ca2a4cb
|
|
| BLAKE2b-256 |
1b3b6d07a912af3a444b17ee01c8d527b12ade5ecec7db0f05735d0e34f81ad0
|