Skip to content

Commit 53aae59

Browse files
authored
Merge pull request #8 from bplommer/bump-ld-sdk
Bump dependencies
2 parents 2538aac + 620a9f8 commit 53aae59

File tree

3 files changed

+81
-43
lines changed

3 files changed

+81
-43
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
strategy:
2929
matrix:
3030
os: [ubuntu-latest]
31-
scala: [2.13.8, 3.1.1]
31+
scala: [2.13.10, 3.2.2]
3232
java: [temurin@8]
3333
project: [rootJVM]
3434
runs-on: ${{ matrix.os }}
@@ -106,7 +106,7 @@ jobs:
106106
strategy:
107107
matrix:
108108
os: [ubuntu-latest]
109-
scala: [2.13.8]
109+
scala: [2.13.10]
110110
java: [temurin@8]
111111
runs-on: ${{ matrix.os }}
112112
steps:
@@ -143,22 +143,22 @@ jobs:
143143
~/Library/Caches/Coursier/v1
144144
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
145145

146-
- name: Download target directories (2.13.8, rootJVM)
146+
- name: Download target directories (2.13.10, rootJVM)
147147
uses: actions/download-artifact@v2
148148
with:
149-
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJVM
149+
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.10-rootJVM
150150

151-
- name: Inflate target directories (2.13.8, rootJVM)
151+
- name: Inflate target directories (2.13.10, rootJVM)
152152
run: |
153153
tar xf targets.tar
154154
rm targets.tar
155155
156-
- name: Download target directories (3.1.1, rootJVM)
156+
- name: Download target directories (3.2.2, rootJVM)
157157
uses: actions/download-artifact@v2
158158
with:
159-
name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.1-rootJVM
159+
name: target-${{ matrix.os }}-${{ matrix.java }}-3.2.2-rootJVM
160160

161-
- name: Inflate target directories (3.1.1, rootJVM)
161+
- name: Inflate target directories (3.2.2, rootJVM)
162162
run: |
163163
tar xf targets.tar
164164
rm targets.tar
@@ -182,7 +182,7 @@ jobs:
182182
strategy:
183183
matrix:
184184
os: [ubuntu-latest]
185-
scala: [2.13.8]
185+
scala: [2.13.10]
186186
java: [temurin@8]
187187
runs-on: ${{ matrix.os }}
188188
steps:

build.sbt

Lines changed: 8 additions & 8 deletions
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.2" // your current series x.y
2+
ThisBuild / tlBaseVersion := "0.3" // your current series x.y
33

44
ThisBuild / organization := "io.github.bplommer"
55
ThisBuild / organizationName := "Ben Plommer"
@@ -16,8 +16,8 @@ ThisBuild / tlSonatypeUseLegacyHost := false
1616
// publish website from this branch
1717
ThisBuild / tlSitePublishBranch := Some("main")
1818

19-
val Scala213 = "2.13.8"
20-
ThisBuild / crossScalaVersions := Seq(Scala213, "3.1.1")
19+
val Scala213 = "2.13.10"
20+
ThisBuild / crossScalaVersions := Seq(Scala213, "3.2.2")
2121
ThisBuild / scalaVersion := Scala213 // the default Scala
2222

2323
lazy val root = tlCrossRootProject.aggregate(core, testkit)
@@ -28,7 +28,7 @@ lazy val testkit = crossProject(JVMPlatform)
2828
.settings(
2929
name := "catapult-testkit",
3030
libraryDependencies ++= Seq(
31-
"com.disneystreaming" %% "weaver-cats" % "0.7.12" % Test
31+
"com.disneystreaming" %% "weaver-cats" % "0.8.1" % Test
3232
),
3333
testFrameworks += new TestFramework("weaver.framework.CatsEffect"),
3434
tlVersionIntroduced := List("2.13", "3").map(_ -> "0.1.0").toMap,
@@ -41,10 +41,10 @@ lazy val core = crossProject(JVMPlatform)
4141
.settings(
4242
name := "catapult",
4343
libraryDependencies ++= Seq(
44-
"org.typelevel" %%% "cats-core" % "2.8.0",
45-
"org.typelevel" %%% "cats-effect" % "3.3.14",
46-
"co.fs2" %%% "fs2-core" % "3.3.0",
47-
"com.launchdarkly" % "launchdarkly-java-server-sdk" % "5.10.3",
44+
"org.typelevel" %%% "cats-core" % "2.9.0",
45+
"org.typelevel" %%% "cats-effect" % "3.4.8",
46+
"co.fs2" %%% "fs2-core" % "3.6.1",
47+
"com.launchdarkly" % "launchdarkly-java-server-sdk" % "6.0.6",
4848
),
4949
)
5050

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

Lines changed: 64 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,40 @@ import cats.effect.{Async, Resource}
2121
import cats.~>
2222
import com.launchdarkly.sdk.server.interfaces.{FlagValueChangeEvent, FlagValueChangeListener}
2323
import com.launchdarkly.sdk.server.{LDClient, LDConfig}
24-
import com.launchdarkly.sdk.{LDUser, LDValue}
24+
import com.launchdarkly.sdk.{LDContext, LDUser, LDValue}
2525
import fs2._
2626

2727
trait LaunchDarklyClient[F[_]] {
28-
def boolVariation(featureKey: String, user: LDUser, defaultValue: Boolean): F[Boolean]
2928

30-
def stringVariation(featureKey: String, user: LDUser, defaultValue: String): F[String]
29+
def boolVariation(featureKey: String, context: LDContext, defaultValue: Boolean): F[Boolean]
3130

32-
def intVariation(featureKey: String, user: LDUser, defaultValue: Int): F[Int]
31+
final def boolVariation(featureKey: String, user: LDUser, defaultValue: Boolean): F[Boolean] =
32+
boolVariation(featureKey, LDContext.fromUser(user), defaultValue)
3333

34-
def doubleVariation(featureKey: String, user: LDUser, defaultValue: Double): F[Double]
34+
def stringVariation(featureKey: String, context: LDContext, defaultValue: String): F[String]
3535

36-
def jsonVariation(featureKey: String, user: LDUser, defaultValue: LDValue): F[LDValue]
36+
final def stringVariation(featureKey: String, user: LDUser, defaultValue: String): F[String] =
37+
stringVariation(featureKey, LDContext.fromUser(user), defaultValue)
3738

38-
def listen(featureKey: String, user: LDUser): Stream[F, FlagValueChangeEvent]
39+
def intVariation(featureKey: String, context: LDContext, defaultValue: Int): F[Int]
40+
41+
final def intVariation(featureKey: String, user: LDUser, defaultValue: Int): F[Int] =
42+
intVariation(featureKey, LDContext.fromUser(user), defaultValue)
43+
44+
def doubleVariation(featureKey: String, context: LDContext, defaultValue: Double): F[Double]
45+
46+
final def doubleVariation(featureKey: String, user: LDUser, defaultValue: Double): F[Double] =
47+
doubleVariation(featureKey, LDContext.fromUser(user), defaultValue)
48+
49+
def jsonVariation(featureKey: String, context: LDContext, defaultValue: LDValue): F[LDValue]
50+
51+
final def jsonVariation(featureKey: String, user: LDUser, defaultValue: LDValue): F[LDValue] =
52+
jsonVariation(featureKey, LDContext.fromUser(user), defaultValue)
53+
54+
def listen(featureKey: String, context: LDContext): Stream[F, FlagValueChangeEvent]
55+
56+
final def listen(featureKey: String, user: LDUser): Stream[F, FlagValueChangeEvent] =
57+
listen(featureKey, LDContext.fromUser(user))
3958

4059
def flush: F[Unit]
4160

@@ -54,17 +73,20 @@ object LaunchDarklyClient {
5473
override def unsafeWithJavaClient[A](f: LDClient => A): F[A] =
5574
F.blocking(f(ldClient))
5675

57-
override def listen(featureKey: String, user: LDUser): Stream[F, FlagValueChangeEvent] =
76+
override def listen(
77+
featureKey: String,
78+
context: LDContext,
79+
): Stream[F, FlagValueChangeEvent] =
5880
Stream.eval(F.delay(ldClient.getFlagTracker)).flatMap { tracker =>
59-
Stream.resource(Dispatcher[F]).flatMap { dispatcher =>
81+
Stream.resource(Dispatcher.sequential[F]).flatMap { dispatcher =>
6082
Stream.eval(Queue.unbounded[F, FlagValueChangeEvent]).flatMap { q =>
6183
val listener = new FlagValueChangeListener {
6284
override def onFlagValueChange(event: FlagValueChangeEvent): Unit =
6385
dispatcher.unsafeRunSync(q.offer(event))
6486
}
6587

6688
Stream.bracket(
67-
F.delay(tracker.addFlagValueChangeListener(featureKey, user, listener))
89+
F.delay(tracker.addFlagValueChangeListener(featureKey, context, listener))
6890
)(listener => F.delay(tracker.removeFlagChangeListener(listener))) >>
6991
Stream.fromQueueUnterminated(q)
7092
}
@@ -77,20 +99,36 @@ object LaunchDarklyClient {
7799
self =>
78100
protected def unsafeWithJavaClient[A](f: LDClient => A): F[A]
79101

80-
override def boolVariation(featureKey: String, user: LDUser, default: Boolean): F[Boolean] =
81-
unsafeWithJavaClient(_.boolVariation(featureKey, user, default))
82-
83-
override def stringVariation(featureKey: String, user: LDUser, default: String): F[String] =
84-
unsafeWithJavaClient(_.stringVariation(featureKey, user, default))
85-
86-
override def intVariation(featureKey: String, user: LDUser, default: Int): F[Int] =
87-
unsafeWithJavaClient(_.intVariation(featureKey, user, default))
88-
89-
override def doubleVariation(featureKey: String, user: LDUser, default: Double): F[Double] =
90-
unsafeWithJavaClient(_.doubleVariation(featureKey, user, default))
91-
92-
override def jsonVariation(featureKey: String, user: LDUser, default: LDValue): F[LDValue] =
93-
unsafeWithJavaClient(_.jsonValueVariation(featureKey, user, default))
102+
override def boolVariation(
103+
featureKey: String,
104+
context: LDContext,
105+
default: Boolean,
106+
): F[Boolean] =
107+
unsafeWithJavaClient(_.boolVariation(featureKey, context, default))
108+
109+
override def stringVariation(
110+
featureKey: String,
111+
context: LDContext,
112+
default: String,
113+
): F[String] =
114+
unsafeWithJavaClient(_.stringVariation(featureKey, context, default))
115+
116+
override def intVariation(featureKey: String, context: LDContext, default: Int): F[Int] =
117+
unsafeWithJavaClient(_.intVariation(featureKey, context, default))
118+
119+
override def doubleVariation(
120+
featureKey: String,
121+
context: LDContext,
122+
default: Double,
123+
): F[Double] =
124+
unsafeWithJavaClient(_.doubleVariation(featureKey, context, default))
125+
126+
override def jsonVariation(
127+
featureKey: String,
128+
context: LDContext,
129+
default: LDValue,
130+
): F[LDValue] =
131+
unsafeWithJavaClient(_.jsonValueVariation(featureKey, context, default))
94132

95133
override def flush: F[Unit] = unsafeWithJavaClient(_.flush())
96134

@@ -99,8 +137,8 @@ object LaunchDarklyClient {
99137
self.unsafeWithJavaClient(f)
100138
)
101139

102-
override def listen(featureKey: String, user: LDUser): Stream[G, FlagValueChangeEvent] =
103-
self.listen(featureKey, user).translate(fk)
140+
override def listen(featureKey: String, context: LDContext): Stream[G, FlagValueChangeEvent] =
141+
self.listen(featureKey, context).translate(fk)
104142

105143
override def flush: G[Unit] = fk(self.flush)
106144
}

0 commit comments

Comments
 (0)