Skip to main content

A module for managing feature flags.

Project description

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

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.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for spartan_module_feature_flag-0.4.1.tar.gz
Algorithm Hash digest
SHA256 38418b26886b42f482390fd7167892517228e1cf58922dd7e56b78bc04a6e2ed
MD5 c94ffa85fecae2ada93bc65466fe530d
BLAKE2b-256 95280ad4fbf7358bc728273cc75caf6b2bee9a92fcca38b1e6a8036b6387abfb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spartan_module_feature_flag-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ad3ff89756f756f1e5687ce2ff9bfc6a10e7aa34f2606c097ac6a0349f220433
MD5 a23fdbc44bac9fc27f0fa4691a021ded
BLAKE2b-256 2b5e7c499099f6f873c501d16ad9e723f728b698df85e574ff9dc7cdc9f215e6

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