Skip to content

Latest commit

 

History

History
87 lines (62 loc) · 4.44 KB

further_reading.md

File metadata and controls

87 lines (62 loc) · 4.44 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 provide options by passing them in when the client is created e.g.

// Create Options
client, err := harness.NewCfClient(myApiKey, 
	harness.WithURL("https://config.ff.harness.io/api/1.0"), 
	harness.WithEventsURL("https://events.ff.harness.io/api/1.0"), 
	harness.WithPullInterval(60),
	harness.WithStreamEnabled(false))
Name Config Option Description default
baseUrl harness.WithURL("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 harness.WithEventsURL("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 harness.WithPullInterval(60)) when running in stream mode, the interval in seconds that we poll for changes. 1
enableStream harness.WithStreamEnabled(false), Enable streaming mode. true
waitForInitialized harness.WithWaitForInitialized(true) When calling NewCfClient , will not return client, err until initialization succeeds of fails false
maxAuthRetries harness.WithMaxAuthRetries(5) The maximum number of attempts that the client will try to authenticate on errors that it deems are retryable. unlimited
enableAnalytics Not Supported Enable analytics. Metrics data is posted every 60s Not Supported

Logging Configuration

You can provide your own logger to the SDK, passing it in as a config option. The following example creates an instance of the logrus logger and provides it as an option.

logger := logrus.New()
logger.SetLevel(logrus.ErrorLevel)

// Create a feature flag client
client, err := harness.NewCfClient(myApiKey, harness.WithLogger(logger))

Recommended reading

Feature Flag Concepts

Feature Flag SDK Concepts

Setting up your Feature Flags

Feature Flags Getting Started

Other Variation Types

String Variation

client.StringVariation(flagName, &target, "default_string")

Number Variation

client.NumberVariation(flagName, &target, -1)

JSON Variation

client.JSONVariation(flagName, &target, types.JSON{"darkmode": false})

Cleanup

Call the close function on the client

client.Close()

Connect to Relay Proxy

When using your Feature Flag SDKs with a Harness Relay Proxy you need to change the default URL. You can pass the URLs in when creating the client. i.e.

	client, err := harness.NewCfClient(apiKey,
		harness.WithURL("http://localhost:7000"),
		harness.WithEventsURL("http://localhost:7000"))