Skip to content

Commit

Permalink
WIP fixing cassandra tests
Browse files Browse the repository at this point in the history
  • Loading branch information
voropaevp committed Dec 13, 2021
1 parent 54c2323 commit 1b156ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
7 changes: 7 additions & 0 deletions build/Dockerfile-cassandra
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ FROM cassandra:3.11.11
MAINTAINER deusaquilus@gmail.com

RUN apt-get update; DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends default-jdk
RUN mv /docker-entrypoint.sh /docker-entrypoint-orig.sh
RUN echo "CREATE KEYSPACE quill_test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;\"" >> /docker-entrypoint.sh && \
echo 'until echo $CQL | cqlsh; do' >> /docker-entrypoint.sh && \
echo 'echo "cqlsh: Cassandra is unavailable to initialize - will retry later"' >> /docker-entrypoint.sh && \
echo 'sleep 2' >> /docker-entrypoint.sh && \
echo 'done' >> /docker-entrypoint.sh && \
echo 'exec /docker-entrypoint-orig.sh "$@"' >> /docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ package io.getquill
import cats._
import cats.effect._
import cats.syntax.all._
import fs2.{Chunk, Stream}
import fs2.{ Chunk, Stream }
import com.typesafe.config.Config
import com.datastax.oss.driver.api.core.cql.Row
import com.datastax.oss.driver.api.core.CqlSession
import com.datastax.oss.driver.api.core.cql.AsyncResultSet
import io.getquill.context.cassandra.CqlIdiom
import io.getquill.util.{ContextLogger, LoadConfig}
import io.getquill.util.{ ContextLogger, LoadConfig }
import io.getquill.context.ExecutionInfo
import io.getquill.context.ce.CeContext

import scala.jdk.CollectionConverters._
import scala.language.higherKinds

class CassandraCeContext[N <: NamingStrategy, F[_]](
naming: N,
session: CqlSession,
preparedStatementCacheSize: Long
)(implicit val af: Async[F])
naming: N,
session: CqlSession,
preparedStatementCacheSize: Long
)(implicit val af: Async[F])
extends CassandraCqlSessionContext[N](naming, session, preparedStatementCacheSize)
with CeContext[CqlIdiom, N, F] {
with CeContext[CqlIdiom, N, F] {

private val logger = ContextLogger(classOf[CassandraCeContext[_, F]])

Expand All @@ -39,8 +39,7 @@ class CassandraCeContext[N <: NamingStrategy, F[_]](
if (rem > 0)
af.delay(Some(Chunk.iterable(rs.currentPage().asScala), rs.remaining()))
else
af.pure(None)
)
af.pure(None))

def streamQuery[T](cql: String, prepare: Prepare = identityPrepare, extractor: Extractor[T] = identityExtractor)(info: ExecutionInfo, dc: Runner): StreamResult[T] = {
Stream
Expand Down Expand Up @@ -71,13 +70,13 @@ class CassandraCeContext[N <: NamingStrategy, F[_]](

object CassandraCeContext {

def apply[N <: NamingStrategy, F[_] : Async : FlatMap](naming: N, config: CassandraContextConfig): CassandraCeContext[N, F] =
def apply[N <: NamingStrategy, F[_]: Async: FlatMap](naming: N, config: CassandraContextConfig): CassandraCeContext[N, F] =
new CassandraCeContext(naming, config.session, config.preparedStatementCacheSize)

def apply[N <: NamingStrategy, F[_] : Async : FlatMap](naming: N, config: Config): CassandraCeContext[N, F] =
def apply[N <: NamingStrategy, F[_]: Async: FlatMap](naming: N, config: Config): CassandraCeContext[N, F] =
CassandraCeContext(naming, CassandraContextConfig(config))

def apply[N <: NamingStrategy, F[_] : Async : FlatMap](naming: N, configPrefix: String): CassandraCeContext[N, F] =
def apply[N <: NamingStrategy, F[_]: Async: FlatMap](naming: N, configPrefix: String): CassandraCeContext[N, F] =
CassandraCeContext(naming, LoadConfig(configPrefix))

}

0 comments on commit 1b156ca

Please sign in to comment.