diff --git a/build.sbt b/build.sbt index 52631d6..ca3e5af 100644 --- a/build.sbt +++ b/build.sbt @@ -81,3 +81,4 @@ lazy val docs = ) } ) + .dependsOn(`flipt-sdk-server`.jvm) diff --git a/docs/index.md b/docs/index.md index 6c3b38f..7f1deb7 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,3 +8,44 @@ - Implementation of a Scala Flipt OpenFeature provider - Implementation of a Scala LaunchDarkly OpenFeature provider, e.g. with [Catalyst](https://typelevel.org/catapult) + +## Installing + +```scala +libraryDependencies += "io.cardell" % "ff4s-flipt-server-sdk" % "@VERSION@" +``` + +## Usage + +```scala mdoc +import cats.effect.IO +import org.http4s.ember.client.EmberClientBuilder +import org.http4s.Uri +import io.cardell.ff4s.flipt.FliptApi +import io.cardell.ff4s.flipt.EvaluationRequest +import io.cardell.ff4s.flipt.auth.AuthenticationStrategy + +val url: Uri = Uri.unsafeFromString("https://flipt.example.com") +val token: String = "token" + +val resource = EmberClientBuilder + .default[IO] + .build + .map(client => + FliptApi[IO](client, url, AuthenticationStrategy.ClientToken("token")) + ) + +resource.use { flipt => + for { + res <- flipt.evaluateBoolean( + EvaluationRequest( + namespaceKey = "default", + flagKey = "my-flag-1", + entityId = None, + context = Map.empty, + reference = None + ) + ) + } yield res.enabled +} +``` diff --git a/flake.nix b/flake.nix index 96eae35..e32b78b 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,7 @@ imports = [ typelevel-nix.typelevelShell ]; name = "ff4s-shell"; typelevelShell = { - jdk.package = pkgs.jdk8; + jdk.package = pkgs.jdk11; nodejs.enable = true; }; };