com.websudos.phantom.example

basics

package basics

Visibility
  1. Public
  2. All

Type Members

  1. sealed class CompositeKeyRecipes extends dsl.CassandraTable[CompositeKeyRecipes, Recipe]

    In this example we will create a table storing recipes.

    In this example we will create a table storing recipes. This time we will use a composite key formed by name and id.

  2. trait ExampleConnector extends SimpleCassandraConnector

    This is an example of how to connect to Cassandra in the easiest possible way.

    This is an example of how to connect to Cassandra in the easiest possible way. The SimpleCassandraConnector is designed to get you up and running immediately, with almost 0 effort.

    What you have to do now is to tell phantom what keyspace you will be using in Cassandra. This connector will automaticalyl try to connect to localhost:9042. If you want to tell the connector to use a different host:port combination, simply override the address inside it.

    Otherwise, simply mixing this connector in will magically inject a database session for all your queries and you can immediately run them.

  3. case class Recipe(id: UUID, name: String, title: String, author: String, description: String, ingredients: Set[String], props: Map[String, String], timestamp: DateTime) extends Product with Serializable

    In this example we will create a simple table storing recipes.

    In this example we will create a simple table storing recipes. Data modeling with com.websudos.phantom is trivial and covers some of the more advanced features of Cassandra.

    Phantom will auto-generate the CQL3 table definition from your Scala code. And you can automatically insert the schema during tests or even live environments.

    This is a very straightforward example, with a non composite Partition key

  4. sealed class Recipes extends dsl.CassandraTable[Recipes, Recipe]

  5. trait SampleModel extends ThriftStruct with Product3[String, String, Option[String]] with Serializable

  6. case class SampleRecord(stuff: String, someList: List[String], thriftModel: SampleModel) extends Product with Serializable

  7. sealed class SecondaryKeyRecipes extends dsl.CassandraTable[SecondaryKeyRecipes, Recipe]

    In this example we will create a table storing recipes with a SecondaryKey.

    In this example we will create a table storing recipes with a SecondaryKey. This time we will use a non-composite Primary key with a SecondaryKey on author.

  8. sealed class ThriftTable extends dsl.CassandraTable[ThriftTable, SampleRecord]

  9. trait ZooKeeperConnector extends DefaultZookeeperConnector

    Now you might ask yourself how to use service discovery with phantom.

    Now you might ask yourself how to use service discovery with phantom. The Datastax Java Driver can automatically connect to multiple clusters. Using some underlying magic, phantom can also help you painlessly connect to a series of nodes in a Cassandra cluster via ZooKeeper.

    Once again, all you need to tell phantom is what your keyspace is. Phantom will make a series of assumptions about which path you are using in ZooKeeper. By default, it will try to connect to localhost:2181, fetch the "/cassandra" path and parse ports found in a "host:port, host1:port1, .." sequence. All these settings are trivial to override in the below connector and you can adjust all the settings to fit your environment.

Value Members

  1. object CompositeKeyRecipes extends CompositeKeyRecipes with ExampleConnector

  2. object Recipes extends Recipes with ExampleConnector

  3. object SampleModel extends ThriftStructCodec3[SampleModel] with Serializable

  4. object SecondaryKeyRecipes extends SecondaryKeyRecipes with ExampleConnector

  5. object ThriftTable extends ThriftTable with ExampleConnector

Ungrouped