Skip to main content

No project description provided

Project description

Flager

PyPI PyPI - Python Version GitHub last commit GitHub stars

Feature flags updater for python

Installation

pip install flager

Features

  • Anyio
  • Abstract code for any backend, e.g., flipt, redis, etc.

Usage

feature flags updater

import asyncio
from dataclasses import dataclass
from typing import Dict, Optional

from flager import FeatureFlagsUpdater


async def show_flags(flags: Dict[str, bool]) -> None:
    while True:
        print(flags)
        await asyncio.sleep(1)


async def main() -> None:
    flags = {"flag_1": False}
    ff_updater = FeatureFlagsUpdater([flags], client=Client(), interval=5)
    await asyncio.gather(ff_updater.run(), show_flags(flags))


@dataclass
class Flag:
    key: str
    enabled: Optional[bool]


class Client:
    flags = {"flag_1": Flag("flag_1", True)}

    async def get_flag(self, key: str) -> Optional[Flag]:
        return self.flags[key]


asyncio.run(main())

feature flag proxy

from flager import FeatureFlagsProxy


async def main() -> None:
    flags = {"flag_1": False}
    flags_proxy = FeatureFlagsProxy(flags, client=Client())
    print(await flags_proxy["flag_1"])

License

Contribution

Contribution guidelines for this project

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

flager-0.1.2.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

flager-0.1.2-py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 3

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