Skip to content

Commit 13a270f

Browse files
Z1kkuratclaude
andauthored
Update scassandra to 5.6.0 (evolution-gaming#881)
5.6.0 deprecates `CassandraSession.state`/`State` in favour of `stateSnapshot`/`StateSnapshot`, so migrate both implementors of `CassandraSession`: - `SessionHelper.Delegate` forwards `stateSnapshot`. It still has to implement the deprecated `state`, which remains abstract upstream, so that member is annotated with `@nowarn`. - `CassandraSessionStub` implements `stateSnapshot` and derives `state` from it. `stateSnapshot` only has a `???` default in 5.6.0 (kept for binary compatibility), so every implementor must override it. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent bacfa6a commit 13a270f

3 files changed

Lines changed: 23 additions & 6 deletions

File tree

persistence-cassandra-it-tests/src/test/scala/com/evolutiongaming/kafka/flow/CassandraSessionStub.scala

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import cats.syntax.all.*
66
import com.datastax.driver.core.{Host, PreparedStatement, RegularStatement, ResultSet, Statement}
77
import com.evolutiongaming.scassandra.CassandraSession
88

9+
import scala.annotation.nowarn
10+
911
object CassandraSessionStub {
1012
// Doesn't inject failures on statements preparation since we don't prepare them on each call.
1113
def injectFailures[F[_]](
@@ -39,11 +41,21 @@ object CassandraSessionStub {
3941
override def prepare(statement: RegularStatement): F[PreparedStatement] =
4042
session.prepare(statement)
4143

44+
override def stateSnapshot: F[CassandraSession.StateSnapshot] = F.pure {
45+
new CassandraSession.StateSnapshot {
46+
override def connectedHosts: Iterable[Host] = Iterable.empty
47+
override def openConnections(host: Host): Int = 0
48+
override def trashedConnections(host: Host): Int = 0
49+
override def inFlightQueries(host: Host): Int = 0
50+
}
51+
}
52+
53+
@nowarn("cat=deprecation")
4254
override def state: CassandraSession.State[F] = new CassandraSession.State[F] {
43-
override def connectedHosts: F[Iterable[Host]] = F.pure(Iterable.empty)
44-
override def openConnections(host: Host): F[Int] = F.pure(0)
45-
override def trashedConnections(host: Host): F[Int] = F.pure(0)
46-
override def inFlightQueries(host: Host): F[Int] = F.pure(0)
55+
override def connectedHosts: F[Iterable[Host]] = stateSnapshot.map(_.connectedHosts)
56+
override def openConnections(host: Host): F[Int] = stateSnapshot.map(_.openConnections(host))
57+
override def trashedConnections(host: Host): F[Int] = stateSnapshot.map(_.trashedConnections(host))
58+
override def inFlightQueries(host: Host): F[Int] = stateSnapshot.map(_.inFlightQueries(host))
4759
}
4860

4961
}

persistence-cassandra/src/main/scala/com/evolutiongaming/kafka/flow/cassandra/SessionHelper.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import com.evolution.scache.Cache
99
import com.evolutiongaming.catshelper.Runtime
1010
import com.evolutiongaming.scassandra.{CassandraSession, NextHostRetryPolicy}
1111

12+
import scala.annotation.nowarn
13+
1214
object SessionHelper {
1315
implicit final class SessionOps[F[_]](val self: CassandraSession[F]) extends AnyVal {
1416
def enhanceError(implicit F: MonadThrow[F]): CassandraSession[F] = {
@@ -73,6 +75,9 @@ object SessionHelper {
7375
def execute(statement: Statement): F[ResultSet] = self.execute(statement)
7476
def prepare(query: String): F[PreparedStatement] = self.prepare(query)
7577
def prepare(statement: RegularStatement): F[PreparedStatement] = self.prepare(statement)
76-
def state: CassandraSession.State[F] = self.state
78+
override def stateSnapshot: F[CassandraSession.StateSnapshot] = self.stateSnapshot
79+
80+
@nowarn("cat=deprecation")
81+
def state: CassandraSession.State[F] = self.state
7782
}
7883
}

project/Dependencies.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object Dependencies {
88
val scache = "com.evolution" %% "scache" % "6.0.1"
99
val skafka = "com.evolutiongaming" %% "skafka" % "21.0.0"
1010
val sstream = "com.evolutiongaming" %% "sstream" % "1.3.0"
11-
val scassandra = "com.evolutiongaming" %% "scassandra" % "5.5.0"
11+
val scassandra = "com.evolutiongaming" %% "scassandra" % "5.6.0"
1212
val cassandraSync = "com.evolutiongaming" %% "cassandra-sync" % "4.0.0"
1313
val random = "com.evolution" %% "random" % "1.0.5"
1414
val retry = "com.evolutiongaming" %% "retry" % "3.1.0"

0 commit comments

Comments
 (0)