Unleash Proxy Client

An Unleash Proxy Client for use when you don't want to evaluate toggles in memory

License

License

Categories

Categories

Kotlin Languages CLI User Interface
GroupId

GroupId

io.getunleash
ArtifactId

ArtifactId

unleash-proxy-client-kotlin
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

Unleash Proxy Client
An Unleash Proxy Client for use when you don't want to evaluate toggles in memory
Project URL

Project URL

https://docs.getunleash.io/unleash-proxy-client-kotlin/index.html
Source Code Management

Source Code Management

https://github.com/Unleash/unleash-proxy-client-kotlin

Download unleash-proxy-client-kotlin

Dependencies

runtime (4)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.4.32
org.jetbrains.kotlinx : kotlinx-serialization-json-jvm jar 1.1.0
com.squareup.okhttp3 : okhttp jar 4.9.1
com.github.ben-manes.caffeine : caffeine jar 3.0.2

Project Modules

There are no modules declared in this project.

Unleash Proxy Client SDK for Kotlin

Coverage Status main latest

This is the Unleash Proxy Client SDK for Kotlin. It is compatible with the unleash-proxy included in our enterprise offering. Though it is written in kotlin, it works seamlessly in Java projects as well

Getting started

You will require the client sdk on your class path.

Maven

<dependency>
    <groupId>io.getunleash</groupId>
    <artifactId>unleash-proxy-client-kotlin</artifactId>
    <version>${CURRENT_VERSION}</version>
</dependency>

Gradle

repositories {
    mavenCentral()
}

dependencies {
    implementation("io.getunleash:unleash-proxy-client-kotlin:$CURRENT_VERSION")
}

Now configure your client instance

You should use this as a singleton to avoid file contention on cache director

val config = UnleashConfig(url = "URL to your proxy", clientKey="API key with access to proxy", appName="The name of your app")
val unleash = UnleashClient(config)

See if a toggle is enabled

if (unleash.isEnabled("my-toggle-name")) {
    println("Our toggle was enabled")
} else {
    println("Our toggle was disabled")
}

If you're using variants you can use

val variant = unleash.getVariant("my-toggle-with-variant")
variant.name.match {
    "orange" -> somethingForOrange()
    else -> somethingelseForEveryoneElse()
}

If you're using variants with payload, the payload has been serialized as a kotlinx.serialization.JsonElement

val variant = unleash.getVariant("my-toggle-variant-with-payload")
val el: JsonElement = variant.payload.value

If you've received new information that you'd like to add your context you can use the updateContext method

val ctx = unleash.getContext().copy(userId = newUserId)
unleash.updateContext(ctx)

Developing

Build

Run

./gradlew build

Releasing

  • Make sure all files are committed
  • Run ./gradlew release
  • Answer prompts

Publishing to maven central

Sonatype username/password

  • Set sonatype username
    • Set sonatypeUsername in your ~/.gradle/gradle.properties
  • Set sonatype password to the api key
    • Set sonatypePassword in your ~/.gradle/gradle.properties

Setup gpg signing

  • Set signing key
    • We're using gpg-agent command to sign, so you'll need to set two properties in your ~/.gradle/gradle.properties - signing.gnupg.keyName - Get it from gpg -K - signing.gnupg.passphrase - The passphrase from your key you just fetched from gpg -K

Publish

  • Standing on tagged commit run
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository`
io.getunleash

Unleash

The Open-Source Feature Toggle Service

Versions

Version
0.1.0