Skip to content

csup performs asynchronous initialization of a Cassandra database and completes a Future, when it finished.

License

Notifications You must be signed in to change notification settings

bjoernjacobs/csup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

csup

csup (Cassandra Up) performs initialization of a Cassandra database given a contact-point, optional credentials, a keyspace name to be created and cql scripts for table creation. The initialization is performed async in a Future and completes with the status of the initalization.

The main use-case of this is when you have an application in a Docker container that is linked with a Cassandra container. When you start-up the containers using e.g. docker-compose, the csup-tool will retry to connect to Cassandra until connection succeeds. Then it will perform the initialization procedure. When the initialization completes, your main application will be notified by the completion of the Future and you can start it up with a ready-to-use Cassandra database.

How to use

Configure your environment using your own application.conf and cassandra_init_statements.conf.

package com.github.bjoernjacobs.csup

import monix.execution.Scheduler.Implicits.global

import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scala.util.{Failure, Success}

object Test extends App {
  val init = CsUp().initGetCluster()

  init.onComplete({
    case Success(cluster) => println(s"Everything cool, here is your cluster: ${cluster.getClusterName}")
    case Failure(ex) => ex.printStackTrace()
  })

  Await.ready(init, Duration.Inf)
  sys.exit()
}

About

csup performs asynchronous initialization of a Cassandra database and completes a Future, when it finished.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages