Giter VIP home page Giter VIP logo

reactive-flows's Introduction

Reactive Flows

Reactive Flows is a demo project showing a Reactive web app built with:

  • Akka Actors
  • Akka HTTP
  • Akka SSE (server-sent events)
  • Akka Distributed Data
  • Akka Cluster Sharding
  • Akka Persistence
  • AngularJS
  • Cassandra
  • Scala
  • etcd

Usage

  • Important: Reactive Flows makes use of server-sent events and advanced JavaScript which aren't available for all browsers, so make sure to use Firefox > 25.0, Safari > 7.1 or Chrome > 45.0
  • To run a single node, simply execute reStart in an sbt session; you can shutdown the app with reStop
  • To run multiple nodes, build a Docker image with docker:publishLocal and execute the script bin/run-reactive-flows.sh without an argument or a number from [0, 10)
  • As the names and labels of the flows aren't persisted, you have to create them after the app has started; see below examples
  • Important: Reactive Flows uses ConstructR for initializing the cluster; make sure etcd is started and available
  • Important: Reactive Flows uses the Cassandra plugin for Akka Persistence; make sure Cassandra is started and available under the configured contact point

Run

Running a single node etcd

Use the host IP address when configuring etcd:

export NODE1=192.168.1.21

Configure a Docker volume to store etcd data:

docker volume create --name etcd-data
export DATA_DIR="etcd-data"

Run the latest version of etcd:

docker run \
  -d \
  -p 2379:2379 \
  -p 2380:2380 \
  --volume=${DATA_DIR}:/etcd-data \
  --name etcd quay.io/coreos/etcd:latest \
  /usr/local/bin/etcd \
  --data-dir=/etcd-data --name node1 \
  --initial-advertise-peer-urls http://${NODE1}:2380 --listen-peer-urls http://0.0.0.0:2380 \
  --advertise-client-urls http://${NODE1}:2379 --listen-client-urls http://0.0.0.0:2379 \
  --initial-cluster node1=http://${NODE1}:2380

Run scylladb

docker run -d --name scylla \
    -p 10000:10000 \
    -p 7000:7000 \
    -p 7001:7001 \
    -p 9042:9042 \
    -p 9160:9160 \
    -p 9180:9180 \
    scylladb/scylla:latest

REST API

http://localhost:8000/flows
http://localhost:8000/flows?label=Akka
http://localhost:8000/flows?label=Scala
http://localhost:8000/flows/akka/posts?text='Akka rocks!'
http://localhost:8000/flows/akka/posts?text='Akka really rocks!'
http://localhost:8000/flows/scala/posts?text='Scala rocks, too!'
http://localhost:8000/flows/scala/posts?text='Scala really rocks, too!'
http://localhost:8000/flows/akka/posts?count==99

Examples

curl -XPOST -H "Content-Type: application/json" \
    http://localhost:8000/flows -d '{"label":"akka"}'
    
curl -XPOST -H "Content-Type: application/json" \
    http://localhost:8000/flows/akka/posts -d '{"text": "akka is cool!"}'

while (true); 
do 
    curl -XPOST -H "Content-Type: application/json" \
        http://localhost:8000/flows/akka/posts -d '{"text": "akka is cool!"}'; 
    sleep 2; 
done

License

This code is open source software licensed under the Apache 2.0 License.

reactive-flows's People

Watchers

James Cloos 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.