A module for managing feature flags.
Project description
from tkinter.constants import DISABLEDfrom tkinter.constants import DISABLEDfrom feature_flag.notification.actions import ChangeStatusfrom feature_flag.notification.actions import ChangeStatus
spartan-module-feature-flag
This module provides a flexible and standardized way to manage feature flags in Python applications. It supports PostgreSQL for persistent storage and optional Redis caching for improved performance.
Features
- CRUD Operations: Create, read, update, and delete feature flags.
- Database Support: PostgreSQL integration.
- Optional Redis Caching: Cache feature flag data for faster access. Redis integration is optional and can be omitted.
- Optional Slack Notifier: Send notification to a Slack channel.
Installation
To install the module and its dependencies, use:
poetry install
Usage
Example Usage
In the examples/basic-usage
directory, you will find a complete example of how to use the Feature Flag module in a FastAPI application.
Slack Notifier
-
Attributes
webhook_url
: This attribute stores the Slack webhook URL used to send messages to the specified Slack channel.excluded_statuses
: This attribute is a list that specifies which status changes should not trigger notifications to the Slack channel.- If set to
None
, all status changes will trigger notifications.
- If set to
-
Sample Code
slack_notifier = SlackNotifier( webhook_url='https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX', excluded_statuses=[ChangeStatus.DELETED, ChangeStatus,DISABLED] )
Development
Debugging & Fixing Issues:
Local Debugging: clone the module repository and install it in "editable" mode using pip install -e .
.
Install
- To install the module and its dev dependencies, use:
poetry install --with dev
Run docker-compose
-
To run the PostgreSQL and Redis services, use:
docker-compose -f docker-compose.ci.yml up -d
-
To shut down the services, use:
docker-compose -f docker-compose.ci.yml down
Testing
To run the tests, use:
-
Unit tests:
poetry run pytest tests/unit
-
Integration tests:
poetry run pytest tests/integration
-
Or we can run all tests:
poetry run pytest tests/
Release
Please follow guidelines in docs/RELEASE.md
Contributors
Duc Duong |
Hao Bui |
Tuong Dang |
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
Built Distribution
File details
Details for the file spartan_module_feature_flag-0.4.0.tar.gz
.
File metadata
- Download URL: spartan_module_feature_flag-0.4.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68fddab3b6b443d9b2f582673f7d43ebf24161267a60807ff714ff5b193e0956 |
|
MD5 | fc6119e2669b0cbe0daefa4f796a945c |
|
BLAKE2b-256 | 5ba45fd10c8d2879169bba666eab92845a0b2412199f6e9c296ad5da90c68347 |
File details
Details for the file spartan_module_feature_flag-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: spartan_module_feature_flag-0.4.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | abcd0c6af23ca116612ff610ee151a6216f89ce3fc097728c7c4a4c5a0d9cdc8 |
|
MD5 | cf128b15a2a264d2ee25191767a911b7 |
|
BLAKE2b-256 | de4965093716f8e83102dc62e14cd517bea8dd302246b85d11d76616aef343ac |