Coder Social home page Coder Social logo

forging2012 / vertx-voting-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from end-of-game/vertx-voting-app

0.0 3.0 0.0 16.91 MB

VertX Voting App

Io 0.26% Shell 5.40% Dockerfile 6.55% TypeScript 27.58% JavaScript 17.63% CSS 4.64% HTML 4.43% Java 33.50%

vertx-voting-app's Introduction

Example Voting App

This application is a rewrite of https://github.com/dockersamples/example-voting-app We only use Java Vertx framework. In next releases, we will introduce other langages as Kotlin, Ceylon or JS. At this day, it is a nice proof-of-concept with the awesome Vertx.

Getting started

Download Docker. If you are on Mac or Windows, Docker Compose will be automatically installed. On Linux, make sure you have the latest version of Compose. Original post comes from there. We rewrote it with VertX.

Build the images in this directory:

mvn clean package docker:build

You should have a similar result with docker images:

 ✘ nicolas@MacBook > ~/software/vertx/vertx-voting-app > master > docker images 
REPOSITORY                              TAG                    IMAGE ID            CREATED             SIZE
vertxswarm/verticle-result             1.0-SNAPSHOT           ebeb1bb53f78        22 minutes ago      450 MB
vertxswarm/verticle-result             1.0-SNAPSHOT.27015db   ebeb1bb53f78        22 minutes ago      450 MB
vertxswarm/verticle-result             latest                 ebeb1bb53f78        22 minutes ago      450 MB
vertxswarm/verticle-worker             1.0-SNAPSHOT           fb702b8f68cf        40 minutes ago      440 MB
vertxswarm/verticle-worker             1.0-SNAPSHOT.27015db   fb702b8f68cf        40 minutes ago      440 MB
vertxswarm/verticle-worker             latest                 fb702b8f68cf        40 minutes ago      440 MB
vertxswarm/verticle-vote               1.0-SNAPSHOT           4b7a5532ba97        40 minutes ago      438 MB
vertxswarm/verticle-vote               1.0-SNAPSHOT.27015db   4b7a5532ba97        40 minutes ago      438 MB
vertxswarm/verticle-vote               latest                 4b7a5532ba97        40 minutes ago      438 MB

Run in this directory:

docker-compose up

The app will be running at:

You can use too if you update your /etc/hosts

Voting server side

Docker Swarm

Alternately, if you want to run it on a Docker Swarm, first make sure you have a swarm. If you don't, run:

Follow this guide to provision a local but complete environment with tutorial Local Docker Swarm.

You can directly use the Shell script

docker-machine create --driver virtualbox poc-manager
docker-machine ssh poc-manager "docker swarm init --advertise-addr $(docker-machine ip poc-manager)"
docker-machine create --driver virtualbox poc-worker1
docker-machine create --driver virtualbox poc-worker2
docker-machine ssh poc-worker1 "docker swarm join --token `docker $(docker-machine config poc-manager) swarm join-token worker -q` $(docker-machine ip poc-manager)"
docker-machine ssh poc-worker2 "docker swarm join --token `docker $(docker-machine config poc-manager) swarm join-token worker -q` $(docker-machine ip poc-manager)"

Once you have your swarm, in this directory run:

docker stack deploy --compose-file docker-stack.yml demo

Architecture

Architecture diagram

  • A verticle webapp which lets you vote between two options
  • A Redis queue which collects new votes
  • A verticle worker which consumes votes and stores them in…
  • A Postgres database backed by a Docker volume
  • A verticle webapp which shows the results of the voting in real time

Technical choice

We choose to use these Maven plugin :

For Verticle vote

For Verticle worker

For Verticle result

In a near future, we will update too :

Note

The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client.

Thanks to

Greetings to:

  • Vertx team
  • Guillaume Borg (from Treeptik)

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.