Skip to main content

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.
  • 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

spartan-ductduong
Duc Duong
spartan-haobui
Hao Bui
spartan-tuongdang
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

spartan_module_feature_flag-0.4.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file spartan_module_feature_flag-0.4.0.tar.gz.

File metadata

File hashes

Hashes for spartan_module_feature_flag-0.4.0.tar.gz
Algorithm Hash digest
SHA256 68fddab3b6b443d9b2f582673f7d43ebf24161267a60807ff714ff5b193e0956
MD5 fc6119e2669b0cbe0daefa4f796a945c
BLAKE2b-256 5ba45fd10c8d2879169bba666eab92845a0b2412199f6e9c296ad5da90c68347

See more details on using hashes here.

File details

Details for the file spartan_module_feature_flag-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for spartan_module_feature_flag-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 abcd0c6af23ca116612ff610ee151a6216f89ce3fc097728c7c4a4c5a0d9cdc8
MD5 cf128b15a2a264d2ee25191767a911b7
BLAKE2b-256 de4965093716f8e83102dc62e14cd517bea8dd302246b85d11d76616aef343ac

See more details on using hashes here.

Supported by

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