Skip to content

Repository files navigation

Catapult

A thin wrapper for the Launch Darkly Java server SDK using cats-effect.

"org.typelevel"%%"catapult"%"latestVersion"

Usage

Basic variations

objectMainextendsIOApp.Simple {
valsdkKey="my-sdk-key"valconfig:LDConfig=newLDConfig.Builder().build()
vallaunchDarklyClientResource:Resource[IO, LaunchDarklyClient[IO]] =LaunchDarklyClient.resource[IO](sdkKey, config)
overridedefrun:IO[Unit] = launchDarklyClientResource.use { client =>for {
// Boolean Variant
bool <- client.boolVariation("BOOL-FLAG", newLDContext("context-name"), defaultValue =false)
_ <-IO.println(s"Boolean Variation: ${bool}")
// String Variant
string <- client.stringVariation("STRING-FLAG", newLDContext("context-name"), defaultValue ="default-string")
_ <-IO.println(s"String Variation: ${string}")
// Integer Variant
int <- client.intVariation("INTEGER-FLAG", newLDContext("context-name"), defaultValue =0)
_ <-IO.println(s"Integer Variation: ${int}")
// Double Variant
double <- client.doubleVariation("DOUBLE-FLAG", newLDContext("context-name"), defaultValue =0.00D)
_ <-IO.println(s"Double Variation: ${double}")
// JSON Variant
json <- client.jsonValueVariation("JSON-FLAG", newLDContext("context-name"), defaultValue =LDValue.of("{}"))
_ <-IO.println(s"JSON Variation: ${json}")
} yield ()
}
}

Flush the buffered event queue

Specifies that any buffered events should be sent as soon as possible, rather than waiting for the next flush interval. The underlying is asynchronous, so events still may not be sent until a later time.

 launchDarklyClientResource.use { client =>
client.flush
}.unsafeRunSync()

Releases

Sponsor this project

Packages

Used by

Contributors

Languages