Skip to main content

GO Feature Flag provider for OpenFeature

Project description

GO Feature Flag Python Provider

GO Feature Flag provider allows you to connect to your GO Feature Flag instance.

GO Feature Flag believes in simplicity and offers a simple and lightweight solution to use feature flags.
Our focus is to avoid any complex infrastructure work to use GO Feature Flag.

This is a complete feature flagging solution with the possibility to target only a group of users, use any types of flags, store your configuration in various location and advanced rollout functionality. You can also collect usage data of your flags and be notified of configuration changes.

Python SDK usage

Install dependencies

The first things we will do is install the Open Feature SDK and the GO Feature Flag provider.

pip install gofeatureflag-python-provider

Initialize your Open Feature client

To evaluate the flags you need to have an Open Feature configured in you app. This code block shows you how you can create a client that you can use in your application.

from gofeatureflag_python_provider.provider import GoFeatureFlagProvider
from gofeatureflag_python_provider.options import GoFeatureFlagOptions
from openfeature import api
from openfeature.evaluation_context import EvaluationContext

# ...

goff_provider = GoFeatureFlagProvider(
    options=GoFeatureFlagOptions(endpoint="https://gofeatureflag.org/")
)
api.set_provider(goff_provider)
client = api.get_client(domain="test-client")

Evaluate your flag

This code block explains how you can create an EvaluationContext and use it to evaluate your flag.

In this example we are evaluating a boolean flag, but other types are available.

Refer to the Open Feature documentation to know more about it.

# Context of your flag evaluation.
# With GO Feature Flag you MUST have a targetingKey that is a unique identifier of the user.
evaluation_ctx = EvaluationContext(
    targeting_key="d45e303a-38c2-11ed-a261-0242ac120002",
    attributes={
        "email": "john.doe@gofeatureflag.org",
        "firstname": "john",
        "lastname": "doe",
        "anonymous": False,
        "professional": True,
        "rate": 3.14,
        "age": 30,
        "company_info": {"name": "my_company", "size": 120},
        "labels": ["pro", "beta"],
    },
)

admin_flag = client.get_boolean_value(
          flag_key=flag_key,
          default_value=default_value,
          evaluation_context=ctx,
      )
      
if admin_flag:
  # flag "flag-only-for-admin" is true for the user
else:
  # flag "flag-only-for-admin" is false for the user

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

gofeatureflag_python_provider-0.2.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file gofeatureflag_python_provider-0.2.1.tar.gz.

File metadata

File hashes

Hashes for gofeatureflag_python_provider-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b2fa11e2a7d5e04b6a7e05221c2e6e17514f8fcd9e18a297bfd9581eb74390db
MD5 c4db9d7567c809f93fe856df59510ac9
BLAKE2b-256 a5c22424b8041da3c15c596cf36bf0722cdc810a95b3840430915a8b645ad5b0

See more details on using hashes here.

File details

Details for the file gofeatureflag_python_provider-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gofeatureflag_python_provider-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 33ea0bd141a9676b4260e16a96a476cee7093c5d99e7f7799368184b27d15016
MD5 ecfd01b8f463a925e7c91b38ab26dd4f
BLAKE2b-256 0c0b2d159f2f68f086f17d60bc394f880c849630fdc49f8557d0d789d332a1d5

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