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

Evaluation modes

The provider supports two evaluation modes:

Mode Description
In-Process (default) Flag configuration is fetched and cached locally; evaluation runs via a WASM module — no per-evaluation network call.
Remote Each flag evaluation makes an HTTP request to the GO Feature Flag relay proxy using the OFREP API.

Initialize your Open Feature client

In-Process evaluation (default)

In-Process evaluation fetches the flag configuration from the relay proxy at startup and on a configurable polling interval. Flags are evaluated locally using a bundled WASM module, which gives you lower latency and no per-evaluation network dependency.

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

goff_provider = GoFeatureFlagProvider(
    options=GoFeatureFlagOptions(
        endpoint="https://gofeatureflag.org/",
        evaluation_type=EvaluationType.INPROCESS,  # default
    )
)
api.set_provider(goff_provider)
client = api.get_client(domain="test-client")

Remote evaluation

Remote evaluation sends each flag evaluation as an HTTP request to the relay proxy.

from gofeatureflag_python_provider.provider import GoFeatureFlagProvider
from gofeatureflag_python_provider.options import GoFeatureFlagOptions, EvaluationType
from openfeature import api

goff_provider = GoFeatureFlagProvider(
    options=GoFeatureFlagOptions(
        endpoint="https://gofeatureflag.org/",
        evaluation_type=EvaluationType.REMOTE,
    )
)
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-only-for-admin",
    default_value=False,
    evaluation_context=evaluation_ctx,
)

if admin_flag:
    # flag "flag-only-for-admin" is true for the user
    pass
else:
    # flag "flag-only-for-admin" is false for the user
    pass

Configuration options

Option Type Default Description
endpoint str (required) URL of the GO Feature Flag relay proxy
evaluation_type EvaluationType INPROCESS Evaluation mode: INPROCESS or REMOTE
cache_size int 10000 Maximum number of flag evaluations kept in the LRU cache (remote mode)
data_flush_interval int 60000 Interval (ms) to flush usage data to the relay proxy
disable_data_collection bool False Set to True to disable usage analytics
reconnect_interval int 60 WebSocket reconnect interval (seconds) (remote mode)
disable_cache_invalidation bool False Disable WebSocket-based cache invalidation (remote mode)
flag_config_poll_interval_seconds int 10 Polling interval (seconds) for flag configuration (in-process mode)
api_key str None API key for authenticated relay proxy requests
exporter_metadata dict {} Static metadata attached to evaluation events
max_pending_events int 10000 Maximum buffered events before a forced flush
wasm_file_path str None Path to a custom WASM/WASI evaluation binary (in-process mode, uses bundled binary by default)
wasm_pool_size int 10 Pool size for concurrent WASM evaluation instances (in-process mode)
log_level str|int "WARNING" Logging level ("DEBUG", "INFO", "WARNING", "ERROR")
urllib3_pool_manager urllib3.PoolManager None Custom HTTP client

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gofeatureflag_python_provider-1.0.1-py3-none-any.whl (311.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gofeatureflag_python_provider-1.0.1.tar.gz
  • Upload date:
  • Size: 372.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gofeatureflag_python_provider-1.0.1.tar.gz
Algorithm Hash digest
SHA256 74b60f48d4cfc492292fb145b770900790a8373551834e3b96678d4bba26d598
MD5 80c645a776088f8dd25d743b8ae21b63
BLAKE2b-256 acd93d769478648050082eec6b307fd62a0a900f1879ccd5d1c3df9be3926680

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gofeatureflag_python_provider-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 311.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gofeatureflag_python_provider-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 34a4dc5b5a5b7d590acb23c1e850d796bfbaf3014a7bf3898ce2cedf3fcba902
MD5 682897106ec4e69553c278dec72020f3
BLAKE2b-256 9f144f796cc49b0b331d8abb77886649f1bdd362aae85ae0e4b0dcaf958dc796

See more details on using hashes here.

Supported by

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