Skip to content

jesperancinha/vma-archiver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vma-archiver


Twitter URL Generic badge GitHub release

CircleCI Build status

vma-archiver e2e-vma-archiver-app

Codacy Badge Build Status Known Vulnerabilities

Coverage Status codecov Codacy Badge

GitHub language count GitHub top language GitHub top language


Technologies used


alt text alt text alt text alt text alt text alt text alt text alt text alt text alt text


Introduction

We are going to make a VMA archiver. VMA in this case does not stand for Video Music Archive anymore. That was version 0.0.0. It now stands for Video Music Awards. So we are going to make a service to register nominees and winners of a VMA show. In this case, we'll use a fake MTV Awards Show. Instead of using contemporary music, we'll make an MTV awards with music and artists from the 1920's.

Our application will be built around the Reactive CoRoutine Paradigms. We'll be using five important elements: Hazelcast, SpringWebFlux, Flow, Kotlin Co-Routines and a nice architecture.

This repo is also the official support repo to my article on medium:

alt text Coroutines, Distributed Cache, Resilience, and Replication in Kotlin β€” Making a VMA’s application

Walk through


Project Layout

  • VMA Demo Generation - Generates The Demo Awards - It is customizable in terms of categories, music and artists.
  • VMA Common - A Common Library to support Spring Boot Startup Services.
  • VMA Play - A way to play with co-routines separated from the project. It has examples on the main and test directories.
  • VMA Spring CoRoutine Reactive Service - The reactive service facing the front-end - It posts votes in Kafka, registers a new award show directly and reads voting results from the database.
  • VMA Service Event Listener - Listens to incoming votes sent in a massive load fashion.
  • Locust - The location of locust service. It creates workers in kotlin that simulate random massive voters.

Endpoints


Install essential libraries and commands

make install

How to start

make docker-clean-build-start

Serving Spring Boot (LOCAL)

In order to let Kafka know where to get to locally you need to define locally that jofisaes-vma-broker is also in 127.0.0.1.

This is done in MAC-OS and Linux machines on /etc/hosts:

127.0.0.1   jofisaes-vma-broker

Knowledge Cloud

BuildersKt.class, Builders.common, withContext, ifEmpty, tailrec, suspend, runBlocking, shuffled , sortedBy, async , await, launch, delay, runBlocking, coroutineScope, Channel, consumeEach, produce, produceSquares , produceNumbers, yield, @Volatile, withContext, Dispatchers.Default, Mutex, CoroutineScope , counterActor, override val massiveRun,


Knowledge for Integration Tests Cloud

@Mockk, @Test, @SpringBootTest


Java Setup

sdk install java 17-open
sdk use java 17-open

Sequence diagram

To visualize this diagram you may need the mermaid-diagrams plugin installation.

To visualize it in Intellij, please install the mermaid plugin.

    sequenceDiagram
        participant VMA Voting Client 1
        participant VMA Voting Client 2
        participant VMA Voting Client n
        participant VMA BE NGINX LB
        participant VMA Services Backend
        participant VMA Kafka Streams
        participant VMA Services Event Listeners
        participant VMA BE HA LB
        participant VMA PostgreSQL
        
        rect rgba(0, 0, 255, .1)
        par
        VMA Voting Client 1-->> VMA BE NGINX LB: Cast vote
        and
        VMA Voting Client 2-->> VMA BE NGINX LB: Cast vote
        and
        VMA Voting Client n-->> VMA BE NGINX LB: Cast vote
        end
        end
        VMA BE NGINX LB-->>VMA Services Backend: Distribute Votes
        VMA Services Backend-->>VMA Kafka Streams: Register Votes
        par
        VMA Kafka Streams-->>VMA Services Backend: Vote registered!
        and
        VMA Kafka Streams-->>VMA Services Event Listeners: Send Register Vote event
        end
        VMA Services Backend-->>VMA BE NGINX LB: Vote registered!
        VMA BE NGINX LB-->>VMA Voting Client 1: Vote registered!
        VMA BE NGINX LB-->>VMA Voting Client 2: Vote registered!
        VMA BE NGINX LB-->>VMA Voting Client n: Vote registered!
        VMA Services Event Listeners-->>VMA PostgreSQL: Create Vote database record
        rect rgba(0, 0, 255, .1)
        par
        VMA Voting Client 1-->> VMA BE NGINX LB: Read votes
        and
        VMA Voting Client 2-->> VMA BE NGINX LB: Read votes
        and
        VMA Voting Client n-->> VMA BE NGINX LB: Read votes
        end
        end
        VMA BE NGINX LB-->>VMA Services Backend: Distribute read votes request
        VMA Services Backend-->>VMA BE HA LB: Request Database Votes
        VMA BE HA LB-->>VMA PostgreSQL: Read Votes
        VMA PostgreSQL-->>VMA BE HA LB: Response with Votes
        VMA BE HA LB-->>VMA Services Backend: Response With Votes
        VMA Services Backend-->>VMA BE NGINX LB: Response With Votes
        VMA BE NGINX LB-->>VMA Voting Client 1: Response With Votes
        VMA BE NGINX LB-->>VMA Voting Client 2: Response With Votes
        VMA BE NGINX LB-->>VMA Voting Client n: Response With Votes
Loading

How to run

  1. Start all containers
make dcup-full

If it fails, you can always try make dcup.


  1. Start Locust
make locust

  1. Cast your vote
    Go to http://localhost:8080 and cast your votes

  1. Wait for locust to stop and check the result
    Go to http://localhost:8080/result

Swagger tests

You can make tests for this application using the Swagger UI at:


References

About me πŸ‘¨πŸ½β€πŸ’»πŸš€πŸ³οΈβ€πŸŒˆ

alt text GitHub followers Twitter Follow alt text | Sessionize | Spotify | Medium | Buy me a coffee | Credly Badges | Google Apps | Sonatype Search Repos | Docker Images | Stack Overflow Profile | Reddit | Dev.TO | Hackernoon | Code Project | BitBucket | GitLab | Coursera | FreeCodeCamp | HackerRank | LeetCode | Codebyte | CodeWars | Code Pen | Hacker Earth | Khan Academy | Hacker News | InfoQ | LinkedIn | Xing | Tumblr | Pinterest | Quora | VMware Spring Professional 2021 | Oracle Certified Professional, Java SE 11 Programmer | Oracle Certified Professional, JEE7 Developer | IBM Cybersecurity Analyst Professional | Certified Advanced JavaScript Developer | Certified Neo4j Professional | Deep Learning | Generic badge Generic badge Generic badge