-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore binary backwards compatibility for CassandraHealthCheck (#595)
- Loading branch information
Showing
5 changed files
with
161 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...src/test/scala/com/evolutiongaming/kafka/journal/cassandra/CassandraHealthCheckSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.evolutiongaming.kafka.journal.cassandra | ||
|
||
import cats.effect.IO | ||
import cats.effect.syntax.all._ | ||
import cats.syntax.all._ | ||
import com.evolutiongaming.catshelper.Log | ||
import com.evolutiongaming.kafka.journal.IOSuite._ | ||
import org.scalatest.funsuite.AsyncFunSuite | ||
|
||
import scala.concurrent.duration._ | ||
import scala.util.control.NoStackTrace | ||
|
||
class CassandraHealthCheckSpec extends AsyncFunSuite { | ||
|
||
test("CassandraHealthCheck#of(statement)") { | ||
|
||
val expectedError = new RuntimeException with NoStackTrace | ||
|
||
val healthCheck = CassandraHealthCheck.of[IO]( | ||
initial = 0.seconds, | ||
interval = 1.second, | ||
statement = expectedError.raiseError[IO, Unit].pure[IO].toResource, | ||
log = Log.empty[IO] | ||
) | ||
|
||
val actualError = healthCheck.use(_.error.untilDefinedM) | ||
|
||
val program = actualError.map { actualError => | ||
assert(actualError == expectedError) | ||
} | ||
|
||
program.run() | ||
} | ||
|
||
} |
29 changes: 0 additions & 29 deletions
29
...scala/com/evolutiongaming/kafka/journal/eventual/cassandra/CassandraHealthCheckSpec.scala
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
...ain/scala/com/evolutiongaming/kafka/journal/eventual/cassandra/CassandraHealthCheck.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.evolutiongaming.kafka.journal.eventual.cassandra | ||
|
||
import cats.Monad | ||
import cats.effect._ | ||
import com.evolutiongaming.catshelper.{Log, LogOf} | ||
import com.evolutiongaming.kafka.journal.cassandra.{CassandraHealthCheck => CassandraHealthCheck2} | ||
import com.evolutiongaming.kafka.journal.eventual.cassandra.EventualCassandraConfig.ConsistencyConfig | ||
|
||
import scala.concurrent.duration._ | ||
|
||
@deprecated(since = "3.3.9", message = "Use a class from `com.evolutiongaming.kafka.journal.cassandra` (without `eventual` part) package instead") | ||
trait CassandraHealthCheck[F[_]] { | ||
def error: F[Option[Throwable]] | ||
} | ||
|
||
@deprecated(since = "3.3.9", message = "Use a class from `com.evolutiongaming.kafka.journal.cassandra` (without `eventual` part) package instead") | ||
object CassandraHealthCheck { | ||
|
||
private[cassandra] def apply[F[_]](cassandraHealthCheck2: CassandraHealthCheck2[F]): CassandraHealthCheck[F] = | ||
new CassandraHealthCheck[F] { | ||
def error: F[Option[Throwable]] = cassandraHealthCheck2.error | ||
} | ||
|
||
def of[F[_] : Temporal : LogOf]( | ||
session: Resource[F, CassandraSession[F]], | ||
consistencyConfig: ConsistencyConfig.Read | ||
): Resource[F, CassandraHealthCheck[F]] = | ||
CassandraHealthCheck2 | ||
.of(session, consistencyConfig.toCassandraConsistencyConfig) | ||
.map(CassandraHealthCheck(_)) | ||
|
||
def of[F[_] : Temporal]( | ||
initial: FiniteDuration, | ||
interval: FiniteDuration, | ||
statement: Resource[F, Statement[F]], | ||
log: Log[F] | ||
): Resource[F, CassandraHealthCheck[F]] = | ||
CassandraHealthCheck2 | ||
.of(initial = initial, interval = interval, statement = statement, log = log) | ||
.map(CassandraHealthCheck(_)) | ||
|
||
|
||
type Statement[F[_]] = CassandraHealthCheck2.Statement[F] | ||
|
||
object Statement { | ||
|
||
def of[F[_] : Monad : CassandraSession](consistency: ConsistencyConfig.Read): F[Statement[F]] = | ||
CassandraHealthCheck2.Statement.of(consistency.toCassandraConsistencyConfig) | ||
|
||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...scala/com/evolutiongaming/kafka/journal/eventual/cassandra/CassandraHealthCheckSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.evolutiongaming.kafka.journal.eventual.cassandra | ||
|
||
import cats.effect.IO | ||
import cats.effect.syntax.all._ | ||
import cats.syntax.all._ | ||
import com.evolutiongaming.catshelper.Log | ||
import com.evolutiongaming.kafka.journal.IOSuite._ | ||
import org.scalatest.funsuite.AsyncFunSuite | ||
|
||
import scala.concurrent.duration._ | ||
import scala.util.control.NoStackTrace | ||
|
||
class CassandraHealthCheckSpec extends AsyncFunSuite { | ||
|
||
test("CassandraHealthCheck#of(statement)") { | ||
|
||
val expectedError = new RuntimeException with NoStackTrace | ||
|
||
val healthCheck = CassandraHealthCheck.of[IO]( | ||
initial = 0.seconds, | ||
interval = 1.second, | ||
statement = expectedError.raiseError[IO, Unit].pure[IO].toResource, | ||
log = Log.empty[IO] | ||
) | ||
|
||
val actualError = healthCheck.use(_.error.untilDefinedM) | ||
|
||
val program = actualError.map { actualError => | ||
assert(actualError == expectedError) | ||
} | ||
|
||
program.run() | ||
} | ||
|
||
} |