-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from kaizen-solutions/modules
Modules
- Loading branch information
Showing
166 changed files
with
2,798 additions
and
1,319 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
.idea/ | ||
.metals/ | ||
target/ | ||
.vscode/ | ||
.vscode/ | ||
metals.sbt |
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,6 @@ | ||
rules = [OrganizeImports] | ||
|
||
OrganizeImports { | ||
// Scala 3.3.x does not support remove unused (although there is a compiler option that detects unused) | ||
removeUnused = false | ||
} |
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
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,2 @@ | ||
addCommandAlias("coverme", "; clean; coverage; test; coverageReport; coverageAggregate") | ||
addCommandAlias("lint", "; scalafmtAll; scalafixAll") |
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
44 changes: 44 additions & 0 deletions
44
cats-effect/src/main/scala/io/kaizensolutions/virgil/CQLExecutor.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,44 @@ | ||
package io.kaizensolutions.virgil | ||
|
||
import cats.effect._ | ||
import com.datastax.oss.driver.api.core.CqlSession | ||
import com.datastax.oss.driver.api.core.CqlSessionBuilder | ||
import com.datastax.oss.driver.api.core.metrics.Metrics | ||
import fs2.Stream | ||
import io.kaizensolutions.virgil.configuration.PageState | ||
import io.kaizensolutions.virgil.internal.CQLExecutorImpl | ||
import io.kaizensolutions.virgil.internal.Proofs.=:!= | ||
|
||
trait CQLExecutor[F[_]] { | ||
def execute[A](in: CQL[A]): Stream[F, A] | ||
|
||
def executeMutation(in: CQL[MutationResult]): F[MutationResult] | ||
|
||
def executePage[A](in: CQL[A], pageState: Option[PageState])(implicit | ||
ev: A =:!= MutationResult | ||
): F[Paged[A]] | ||
|
||
def metrics: F[Option[Metrics]] | ||
} | ||
object CQLExecutor { | ||
|
||
/** | ||
* Create a CQL Executor from an existing Datastax Java Driver's CqlSession | ||
* Note that the user is responsible for the lifecycle of the underlying | ||
* CqlSession | ||
* @param session | ||
* is the underlying Datastax Java Driver's CqlSession | ||
* @return | ||
* the CQLExecutor | ||
*/ | ||
def fromCqlSession[F[_]: Async](session: CqlSession): CQLExecutor[F] = | ||
new CQLExecutorImpl[F](session) | ||
|
||
def apply[F[_]](builder: => CqlSessionBuilder)(implicit F: Async[F]): Resource[F, CQLExecutor[F]] = { | ||
val acquire: F[CqlSession] = F.delay(builder.build()) | ||
val release: CqlSession => F[Unit] = (session: CqlSession) => F.delay(session.close()) | ||
Resource | ||
.make[F, CqlSession](acquire)(release) | ||
.map(new CQLExecutorImpl[F](_)) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
cats-effect/src/main/scala/io/kaizensolutions/virgil/Paged.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,6 @@ | ||
package io.kaizensolutions.virgil | ||
|
||
import fs2.Chunk | ||
import io.kaizensolutions.virgil.configuration.PageState | ||
|
||
final case class Paged[A](data: Chunk[A], pageState: Option[PageState]) |
17 changes: 17 additions & 0 deletions
17
...ect/src/main/scala/io/kaizensolutions/virgil/codecs/CqlPrimitiveDecoderFS2Instances.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,17 @@ | ||
package io.kaizensolutions.virgil.codecs | ||
|
||
import fs2.Chunk | ||
import io.kaizensolutions.virgil.codecs.CqlPrimitiveDecoder.ListPrimitiveDecoder | ||
|
||
import scala.jdk.CollectionConverters._ | ||
|
||
trait CqlPrimitiveDecoderFS2Instances { | ||
implicit def chunkCqlPrimitiveDecoder[A](implicit | ||
element: CqlPrimitiveDecoder[A] | ||
): CqlPrimitiveDecoder.WithDriver[Chunk[A], java.util.List[element.DriverType]] = | ||
ListPrimitiveDecoder[Chunk, A, element.DriverType]( | ||
element, | ||
(driverList, transformElement) => Chunk.iterable(driverList.asScala.map(transformElement)) | ||
) | ||
} | ||
object CqlPrimitiveDecoderFS2Instances extends CqlPrimitiveDecoderFS2Instances |
18 changes: 18 additions & 0 deletions
18
...ect/src/main/scala/io/kaizensolutions/virgil/codecs/CqlPrimitiveEncoderFS2Instances.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,18 @@ | ||
package io.kaizensolutions.virgil.codecs | ||
|
||
import fs2.Chunk | ||
import io.kaizensolutions.virgil.codecs.CqlPrimitiveEncoder.ListPrimitiveEncoder | ||
|
||
import scala.jdk.CollectionConverters._ | ||
|
||
trait CqlPrimitiveEncoderFS2Instances { | ||
implicit def chunkCqlPrimitiveEncoder[A](implicit | ||
element: CqlPrimitiveEncoder[A] | ||
): ListPrimitiveEncoder[Chunk, A, element.DriverType] = | ||
ListPrimitiveEncoder[Chunk, A, element.DriverType]( | ||
element, | ||
(chunk, transform) => chunk.map(transform).toList.asJava | ||
) | ||
} | ||
|
||
object CqlPrimitiveEncoderFS2Instances extends CqlPrimitiveEncoderFS2Instances |
Oops, something went wrong.