Skip to content

Latest commit

 

History

History
101 lines (75 loc) · 4.8 KB

further_reading.md

File metadata and controls

101 lines (75 loc) · 4.8 KB

Further Reading

Covers advanced topics (different config options and scenarios)

Configuration Options

The following configuration options are available to control the behaviour of the SDK. You can pass the configuration in as options when the SDK client is created.

    # Create a Feature Flag Client
    client = CfClient(apiKey,
                      with_base_url("https://config.ff.harness.io/api/1.0"),
                      with_events_url("https://events.ff.harness.io/api/1.0"),
                      with_stream_enabled(True),
                      with_analytics_enabled(True),
                      Config(pull_interval=60))
Name Config Option Description default
baseUrl with_base_url("https://config.ff.harness.io/api/1.0") the URL used to fetch feature flag evaluations. You should change this when using the Feature Flag proxy to http://localhost:7000 https://config.ff.harness.io/api/1.0
eventsUrl with_events_url("https://events.ff.harness.io/api/1.0"), the URL used to post metrics data to the feature flag service. You should change this when using the Feature Flag proxy to http://localhost:7000 https://events.ff.harness.io/api/1.0
pollInterval Config(pull_interval=60) when running in stream mode, the interval in seconds that we poll for changes. 60
enableStream with_stream_enabled(True), Enable streaming mode. true
enableAnalytics with_analytics_enabled(True) Enable analytics. Metrics data is posted every 60s true
pollInterval with_poll_interval(120) When running in stream mode, the interval in seconds that we poll for changes. 60

Logging Configuration

The SDK provides a logger that wraps the standard python logging package. You can import and use it with:

from featureflags.util import log
log.info("Hello, World!")

If you want to change the default log level, you can use the standard logging levels

from featureflags.util import log
import logging

log.setLevel(logging.WARN)

Recommended reading

Feature Flag Concepts

Feature Flag SDK Concepts

Setting up your Feature Flags

Feature Flags Getting Started

Other Variation Types

String Variation

client.string_variation('identifier_of_your_string_flag', target, "default string")

Example

Number Variation

client.number_variation('identifier_of_your_number_flag', target, -1)

Example

JSON Variation

client.json_variation('identifier_of_your_json_flag', target, {})

Example

Cleanup

Call the close function on the client

client.close()

Example

Change default URL

When using your Feature Flag SDKs with a Harness Relay Proxy you need to change the default URL.

To do this you import the url helper functions

from featureflags.config import with_base_url
from featureflags.config import with_events_url

Then pass them with the new URLs when creating your client.

    client = CfClient(api_key,
                      with_base_url("https://config.feature-flags.uat.harness.io/api/1.0"),
                      with_events_url("https://event.feature-flags.uat.harness.io/api/1.0"))

Example