GithubHelp home page GithubHelp logo

alvintamie / play2-scala-cassandra-sample Goto Github PK

View Code? Open in Web Editor NEW

This project forked from magro/play2-scala-cassandra-sample

0.0 3.0 0.0 188 KB

Play Framework 2 Scala sample application that shows how to access Cassandra using the DataStax driver and its asynchronous API.

License: Apache License 2.0

Scala 71.45% HTML 2.88% Ruby 23.42% Shell 2.25%

play2-scala-cassandra-sample's Introduction

Play2 Scala Cassandra Sample App

This Play Framework 2 sample application shows how to access Cassandra from Scala using the DataStax Java Driver 2.0 and its asynchronous capabilities. The app allows to retrieve and store Songs (via JSON).

Usage

Start Cassandra

At first you should start Cassandra, you can just use the provided Vagrantfile (using the ) for this. If you haven't already installed Vagrant, head over to the Vagrant Installation page and get Vagrant.

The Vagrantfile uses the precise32 image, which you have to download once:

$ vagrant box add precise32 http://files.vagrantup.com/precise32.box

After that you can boot the vagrant box that will install Cassandra on its first start.

$ cd vagrant
$ vagrant up

Start the Application

As with every Play 2 application, just use play run.

How to Play

On the first start some data is inserted into Cassandra, in our case we're working with songs. To retrieve the list of stored songs point your browser to localhost:9000.

To insert another song you have to POST some json, here's how to do this with curl:

$ curl -v -X POST -H "Content-Type: application/json" \
  -d '{"title":"The Unforgiven","album":"Black Album","artist":"Metallica"}' \
  http://localhost:9000

You should get 201/Created as response status and a Location header that tells you which resource was created for the new Song.

Configuration

The hostname/IP address of the Cassandra cluster is configured in conf/application.conf. Right now only a single node is supported, this could easily be extended to take a list of nodes. The configuration is evaluated in app/Global.scala, which creates the SimpleClient to connect to Cassandra.

License

Apache 2.0

play2-scala-cassandra-sample's People

Contributors

magro avatar

Watchers

James Cloos avatar Alvin Francis Tamie avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.