Skip to main content

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 (Optional): 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.
    • headers (Optional): A dictionary where you can specify additional HTTP headers to include in the Slack notification requests.
  • Sample Code

    slack_notifier = SlackNotifier(
      webhook_url='https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX',
      excluded_statuses=[ChangeStatus.DELETED, ChangeStatus,DISABLED],
      headers = {
        "Authorization": "Bearer xoxb-your-slack-token",
        "Content-Type": "application/json"
      }
    )
    

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

Release files for spartan-module-feature-flag 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spartan-module-feature-flag 0.4.1
File Size Uploaded
spartan_module_feature_flag-0.4.1.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spartan-module-feature-flag 0.4.1
File Interpreter ABI Platform
spartan_module_feature_flag-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.7 kB

Release files / spartan_module_feature_flag-0.4.1.tar.gz

Download URL spartan_module_feature_flag-0.4.1.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
38418b26886b42f482390fd7167892517228e1cf58922dd7e56b78bc04a6e2ed
BLAKE2b-256 checksum
How to use checksums
95280ad4fbf7358bc728273cc75caf6b2bee9a92fcca38b1e6a8036b6387abfb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / spartan_module_feature_flag-0.4.1-py3-none-any.whl

Download URL spartan_module_feature_flag-0.4.1-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad3ff89756f756f1e5687ce2ff9bfc6a10e7aa34f2606c097ac6a0349f220433
BLAKE2b-256 checksum
How to use checksums
2b5e7c499099f6f873c501d16ad9e723f728b698df85e574ff9dc7cdc9f215e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.7

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page