-
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Thomas Poignant <[email protected]>
- Loading branch information
1 parent
1647739
commit bfa5ef1
Showing
26 changed files
with
952 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# GO Feature Flag Kotlin OpenFeature Provider for Android | ||
|
||
![Static Badge](https://img.shields.io/badge/status-experimental-red) | ||
|
||
This OpenFeature provider is 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](https://gofeatureflag.org) 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](https://gofeatureflag.org/docs/openfeature_sdk/server_providers/openfeature_java). | ||
|
||
## What is GO Feature Flag? | ||
|
||
GO Feature Flag is a simple, complete and lightweight self-hosted feature flag solution 100% Open | ||
Source. | ||
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. | ||
|
||
## Install the provider | ||
|
||
TODO | ||
|
||
## How to use the provider? | ||
|
||
```kotlin | ||
val evaluationContext = ImmutableContext( | ||
targetingKey = "0a23d9a5-0a8f-42c9-9f5f-4de3afd6cf99", | ||
attributes = mutableMapOf( | ||
"region" to Value.String("us-east-1"), | ||
"email" to Value.String("[email protected]") | ||
) | ||
) | ||
|
||
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 | | ||
|
||
<sub>Implemented: ✅ | In-progress: ⚠️ | Not implemented yet: ❌</sub> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
plugins { | ||
id("com.android.application") version "8.1.2" apply false | ||
id("org.jetbrains.kotlin.android") version "1.9.0" apply false | ||
id("com.android.library") version "8.1.2" apply false | ||
} | ||
|
||
allprojects { | ||
extra["groupId"] = "org.gofeatureflag.openfeature" | ||
ext["version"] = "0.0.1" | ||
} | ||
|
||
group = project.extra["groupId"].toString() | ||
version = project.extra["version"].toString() |
1 change: 1 addition & 0 deletions
1
openfeature/providers/kotlin-provider/gofeatureflag-kotlin-provider/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
44 changes: 44 additions & 0 deletions
44
openfeature/providers/kotlin-provider/gofeatureflag-kotlin-provider/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
plugins { | ||
id("com.android.library") | ||
id("org.jetbrains.kotlin.android") | ||
} | ||
|
||
val releaseVersion = project.extra["version"].toString() | ||
|
||
android { | ||
namespace = "org.gofeatureflag.openfeature" | ||
compileSdk = 33 | ||
|
||
defaultConfig { | ||
minSdk = 21 | ||
version = releaseVersion | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_11.toString() | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation("dev.openfeature:kotlin-sdk:0.0.4") | ||
implementation("com.squareup.okhttp3:okhttp:4.12.0") | ||
implementation("com.google.code.gson:gson:2.8.9") | ||
implementation("dev.gustavoavila:java-android-websocket-client:2.0.2") | ||
testImplementation("junit:junit:4.13.2") | ||
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3") | ||
testImplementation("com.squareup.okhttp3:mockwebserver:4.12.0") | ||
} |
Empty file.
21 changes: 21 additions & 0 deletions
21
openfeature/providers/kotlin-provider/gofeatureflag-kotlin-provider/proguard-rules.pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
4 changes: 4 additions & 0 deletions
4
...ture/providers/kotlin-provider/gofeatureflag-kotlin-provider/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
9 changes: 9 additions & 0 deletions
9
...flag-kotlin-provider/src/main/java/org/gofeatureflag/openfeature/GoFeatureFlagMetadata.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.gofeatureflag.openfeature | ||
|
||
import dev.openfeature.sdk.ProviderMetadata | ||
import java.security.Provider | ||
|
||
class GoFeatureFlagMetadata() : ProviderMetadata { | ||
override val name: String | ||
get() = "GoFeatureFlagProvider" | ||
} |
Oops, something went wrong.