jsfwa / zio-cassandra

Just alternative wrapper for zio, inspired by akka(alpakka)-cassandra

Version Matrix

Release Artifacts Snapshot Artifacts

zio-cassandra

scala = 2.13.3
cassandra-driver = 4.8.0
zio = 1.0.1

Inspired by akka/alpakka-cassandra

Usage

Dependency:

libraryDependencies += "io.github.jsfwa" %% "zio-cassandra" % "1.0.0"

Check driver config documentation on datastax

// Cassandra Session:
  val session = CassandraSession.make(config)
//OR
  val session = CassandraSession.make(cqlSessionBuilder)

// Use:
  val job = for {
    session  <- ZIO.service[CassandraSession]
    _        <- session.execute("insert ...")
    prepared <- session.prepare("select ...")
    select   <- session.bind(prepared, Seq(args))
    row      <- session.selectOne(select, profileName = "oltp")
  } yield row
  
  job.provideCustomLayer(CassandraSession.make(config).toLayer)