Android / Kotlin
This OpenFeature provider has a Kotlin implementation for Android to communicate with the GO Feature Flag Server.
The OpenFeature Kotlin is experimental, and the provider is also experimental.
We don't recommend using this in production yet.
About this provider
GO Feature Flag provider allows you to connect to your GO Feature Flag instance with the OpenFeature Kotlin SDK.
This is a client provider made for Android, we do not recommend using it in a server environment.
If you want to use it in a server environment, you should use
the Java
provider.
Install the provider
- gradle
- maven
implementation("org.gofeatureflag.openfeature:gofeatureflag-kotlin-provider:0.0.1-beta.1")
api("dev.openfeature:android-sdk:0.3.0")
implementation("org.gofeatureflag.openfeature:gofeatureflag-kotlin-provider0.0.1-beta.2")
<dependency>
<groupId>dev.openfeature</groupId>
<artifactId>sdk</artifactId>
<artifactId>0.3.0</artifactId>
</dependency>
<dependency>
<groupId>org.gofeatureflag.openfeature</groupId>
<artifactId>gofeatureflag-kotlin-provider</artifactId>
<version>0.0.1-beta.2</version>
</dependency>
How to use the provider?
val evaluationContext = ImmutableContext(
targetingKey = "0a23d9a5-0a8f-42c9-9f5f-4de3afd6cf99",
attributes = mutableMapOf(
"region" to Value.String("us-east-1"),
"email" to Value.String("john.doe@gofeatureflag.org")
)
)
OpenFeatureAPI.setProvider(
GoFeatureFlagProvider(
options = GoFeatureFlagOptions(
endpoint = "http://localhost:1031"
)
), evaluationContext
)
val client = OpenFeatureAPI.getClient("my-client")
if (client.getBooleanValue("my-flag", false)) {
println("my-flag is enabled")
}
OpenFeatureAPI.shutdown()
Available options
Option name | Type | Default | Description |
---|---|---|---|
endpoint | String | endpoint is the URL where your GO Feature Flag server is located. | |
timeout | Long | 10000 | (optional) timeout is the time in millisecond we wait for an answer from the server. |
maxIdleConnections | Int | 1000 | (optional) maxIdleConnections is the maximum number of connexions in the connexion pool. |
keepAliveDuration | Long | 7200000 | (optional) keepAliveDuration is the time in millisecond we keep the connexion open. |
apiKey | String | (optional) If GO Feature Flag is configured to authenticate the requests, you should provide an API Key to the provider. Please ask the administrator of the relay proxy to provide an API Key. | |
retryDelay | Long | 300 | (optional) delay in millisecond to wait before retrying to connect the websocket |
Reconnection
If the connection to the GO Feature Flag instance fails, the provider will attempt to reconnect.
Event streaming
Event streaming is not implemented yet in the GO Feature Flag provider.
Features status
Status | Feature | Description |
---|---|---|
✅ | Flag evaluation | It is possible to evaluate all the type of flags |
✅ | Cache invalidation | Websocket mechanism is in place to refresh the cache in case of configuration change |
❌ | Logging | Not supported by the SDK |
❌ | Flag Metadata | Not supported by the SDK |
❌ | Event Streaming | Not implemented |
❌ | Unit test | Not implemented |