Skip to content

configcat/openfeature-kotlin

Repository files navigation

ConfigCat OpenFeature Provider for Kotlin

CI Maven Central

This repository contains an OpenFeature provider that allows ConfigCat to be used with the OpenFeature Kotlin SDK.

Installation

dependencies {
    implementation("com.configcat:configcat-openfeature-provider:$providerVersion")
}

Usage

The ConfigCatProvider function takes the SDK key and an optional ConfigCatOptions argument containing the additional configuration options for the ConfigCat Kotlin SDK:

import com.configcat.*
import dev.openfeature.sdk.*

coroutineScope.launch(Dispatchers.IO) {
    // Configure the provider.
    val provider = ConfigCatProvider("<YOUR-CONFIGCAT-SDK-KEY>") {
        pollingMode = autoPoll { pollingInterval = 60.seconds }
    }

    // Configure the OpenFeature API with the ConfigCat provider.
    OpenFeatureAPI.setProviderAndWait(provider)

    // Create a client.
    val client = OpenFeatureAPI.getClient()

    // Evaluate feature flag.
    val isAwesomeFeatureEnabled = client.getBooleanValue("isAwesomeFeatureEnabled", false)
}

For more information about all the configuration options, see the Kotlin SDK documentation.

Need help?

https://configcat.com/support

Contributing

Contributions are welcome. For more info please read the Contribution Guideline.

About ConfigCat

ConfigCat is a feature flag and configuration management service that lets you separate releases from deployments. You can turn your features ON/OFF using ConfigCat Dashboard even after they are deployed. ConfigCat lets you target specific groups of users based on region, email or any other custom user attribute.

ConfigCat is a hosted feature flag service. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.