Package

com.websudos.phantom.example

basics

Permalink

package basics

Visibility
  1. Public
  2. All

Type Members

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

    Permalink

    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. abstract class ConcreteCompositeKeyRecipes extends CompositeKeyRecipes with RootConnector

    Permalink
  3. abstract class ConcreteRecipes extends Recipes with RootConnector

    Permalink
  4. abstract class ConcreteSecondaryKeyRecipes extends SecondaryKeyRecipes with RootConnector

    Permalink
  5. abstract class ConcreteThriftTable extends ThriftTable with RootConnector

    Permalink
  6. trait DefaultZookeeperConnector extends RootConnector

    Permalink
  7. trait DockerConnector extends Connector

    Permalink
  8. trait ExampleConnector extends Connector

    Permalink

    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.

  9. trait KeyspaceDefinition extends AnyRef

    Permalink
  10. 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

    Permalink

    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

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

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

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

    Permalink
  14. sealed class SecondaryKeyRecipes extends dsl.CassandraTable[ConcreteSecondaryKeyRecipes, Recipe]

    Permalink

    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.

  15. sealed class ThriftTable extends dsl.CassandraTable[ConcreteThriftTable, SampleRecord]

    Permalink

Value Members

  1. object Defaults extends KeyspaceDefinition

    Permalink
  2. object RemoteConnector extends KeyspaceDefinition

    Permalink

    This is an example of how to connect to a custom set of hosts and ports.

    This is an example of how to connect to a custom set of hosts and ports. First, we need to obtain a connector and keep a singleton reference to it. It's really important to guarantee we are using a singleton here, otherwise we will end up spawning a cluster on every call.

  3. object SampleModel extends ThriftStructCodec3[SampleModel] with Serializable

    Permalink
  4. object ZkDefaults extends KeyspaceDefinition

    Permalink

    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.

Ungrouped