Skip to content

Commit 98ec8b2

Browse files
authored
Merge pull request #89 from typelevel/method-names-match-java-sdk
Rename client methods
2 parents c8fc57f + 6c0767f commit 98ec8b2

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ A thin wrapper for the [Launch Darkly Java server SDK](https://github.com/launch
3535
_ <- IO.println(s"Double Variation: ${double}")
3636

3737
// JSON Variant
38-
json <- client.jsonVariation("JSON-FLAG", new LDContext("context-name"), defaultValue = LDValue.of("{}"))
38+
json <- client.jsonValueVariation("JSON-FLAG", new LDContext("context-name"), defaultValue = LDValue.of("{}"))
3939
_ <- IO.println(s"JSON Variation: ${json}")
4040
} yield ()
4141
}

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// https://typelevel.org/sbt-typelevel/faq.html#what-is-a-base-version-anyway
2-
ThisBuild / tlBaseVersion := "0.4" // your current series x.y
2+
ThisBuild / tlBaseVersion := "0.5" // your current series x.y
33

44
ThisBuild / organization := "org.typelevel"
55
ThisBuild / organizationName := "Typelevel"

core/src/main/scala/org.typelevel/catapult/LaunchDarklyClient.scala

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,35 @@ trait LaunchDarklyClient[F[_]] {
8181
* @return the flag value, suspended in the `F` effect. If evaluation fails for any reason, returns the default value.
8282
* @see [[https://javadoc.io/doc/com.launchdarkly/launchdarkly-java-server-sdk/latest/com/launchdarkly/sdk/server/interfaces/LDClientInterface.html#jsonValueVariation(java.lang.String,com.launchdarkly.sdk.LDContext,com.launchdarkly.sdk.LDValue) LDClientInterface#jsonValueVariation]]
8383
*/
84-
def jsonVariation[Ctx: ContextEncoder](
84+
def jsonValueVariation[Ctx: ContextEncoder](
8585
featureKey: String,
8686
context: Ctx,
8787
defaultValue: LDValue,
8888
): F[LDValue]
8989

90+
@deprecated("use jsonValueVariation", "0.5.0")
91+
final def jsonVariation[Ctx: ContextEncoder](
92+
featureKey: String,
93+
context: Ctx,
94+
defaultValue: LDValue,
95+
): F[LDValue] = jsonValueVariation(featureKey, context, defaultValue)
96+
9097
/** @param featureKey the key of the flag to be evaluated
9198
* @param context the context against which the flag is being evaluated
9299
* @tparam Ctx the type representing the context; this can be [[https://javadoc.io/doc/com.launchdarkly/launchdarkly-java-server-sdk/latest/com/launchdarkly/sdk/LDContext.html LDContext]], [[https://javadoc.io/doc/com.launchdarkly/launchdarkly-java-server-sdk/latest/com/launchdarkly/sdk/LDUser.html LDUser]], or any type with a [[ContextEncoder]] instance in scope.
93100
* @return A `Stream` of [[https://javadoc.io/doc/com.launchdarkly/launchdarkly-java-server-sdk/latest/com/launchdarkly/sdk/server/interfaces/FlagValueChangeEvent.html FlagValueChangeEvent]] instances representing changes to the value of the flag in the provided context. Note: if the flag value changes multiple times in quick succession, some intermediate values may be missed; for example, a change from 1` to `2` to `3` may be represented only as a change from `1` to `3`
94101
* @see [[https://javadoc.io/doc/com.launchdarkly/launchdarkly-java-server-sdk/latest/com/launchdarkly/sdk/server/interfaces/FlagTracker.html FlagTracker]]
95102
*/
96-
def listen[Ctx: ContextEncoder](featureKey: String, context: Ctx): Stream[F, FlagValueChangeEvent]
103+
def trackFlagValueChanges[Ctx: ContextEncoder](
104+
featureKey: String,
105+
context: Ctx,
106+
): Stream[F, FlagValueChangeEvent]
107+
108+
@deprecated("use trackFlagValueChanges", "0.5.0")
109+
final def listen[Ctx: ContextEncoder](
110+
featureKey: String,
111+
context: Ctx,
112+
): Stream[F, FlagValueChangeEvent] = trackFlagValueChanges(featureKey, context)
97113

98114
/** @see [[https://javadoc.io/doc/com.launchdarkly/launchdarkly-java-server-sdk/latest/com/launchdarkly/sdk/server/interfaces/LDClientInterface.html#flush() LDClientInterface#flush]]
99115
*/
@@ -131,7 +147,7 @@ object LaunchDarklyClient {
131147
override def unsafeWithJavaClient[A](f: LDClient => A): F[A] =
132148
F.blocking(f(ldClient))
133149

134-
override def listen[Ctx](
150+
override def trackFlagValueChanges[Ctx](
135151
featureKey: String,
136152
context: Ctx,
137153
)(implicit ctxEncoder: ContextEncoder[Ctx]): Stream[F, FlagValueChangeEvent] =
@@ -188,7 +204,7 @@ object LaunchDarklyClient {
188204
)(implicit ctxEncoder: ContextEncoder[Ctx]): F[Double] =
189205
unsafeWithJavaClient(_.doubleVariation(featureKey, ctxEncoder.encode(context), default))
190206

191-
override def jsonVariation[Ctx](
207+
override def jsonValueVariation[Ctx](
192208
featureKey: String,
193209
context: Ctx,
194210
default: LDValue,
@@ -202,10 +218,10 @@ object LaunchDarklyClient {
202218
self.unsafeWithJavaClient(f)
203219
)
204220

205-
override def listen[Ctx](featureKey: String, context: Ctx)(implicit
221+
override def trackFlagValueChanges[Ctx](featureKey: String, context: Ctx)(implicit
206222
ctxEncoder: ContextEncoder[Ctx]
207223
): Stream[G, FlagValueChangeEvent] =
208-
self.listen(featureKey, context).translate(fk)
224+
self.trackFlagValueChanges(featureKey, context).translate(fk)
209225

210226
override def flush: G[Unit] = fk(self.flush)
211227
}

testkit/src/test/scala/org/typelevel/catapult/VariationTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ object VariationTests extends SimpleIOSuite {
5252
received <- IO.ref[Chain[FlagValueChangeEvent]](Chain.empty)
5353
_ <- sup.supervise(
5454
client
55-
.listen("foo", LDContext.create("testContext"))
55+
.trackFlagValueChanges("foo", LDContext.create("testContext"))
5656
.evalTap(event => received.update(_.append(event)))
5757
.compile
5858
.drain

0 commit comments

Comments
 (0)