Coder Social home page Coder Social logo

prime-grpc-scala-akka's Introduction

prime-grpc-scala-akka

Head to Wiki for detailed design docs.

Install Dependencies

  1. Install SBT

    On linux/windows based systems, you can use SDKMAN software development kit manager for convenient installation and usage of multiple versions.

  2. Install Docker

    Follow docker installation guide here.

  3. Install Minikube/Kubectl

    Use following convenience script to install both minikube and kubectl.

    $ ./deploy/scripts/setup-minikube-for-linux.sh

Build

1. Publish Protobuf Sources

Protobuf files are maintained in a separate sbt project to avoid maintaining them in both client and server.

$ cd prime-protobuf
$ sbt +publishLocal

Note: The project can be cross-compiled to multiple Scala versions. Should you choose to compile it into a Scala version of your choice, don't forget to update build.sbt with desired Scala version.

2. Publish Docker Images

$ sbt prime-generator/docker:publishLocal
$ sbt prime-proxy/docker:publishLocal

Note: Make sure to point local docker daemon to minikube internal docker registry to make the docker images available inside minikube cluster. Use following command.

$ eval $(minikube -p minikube docker-env)

Deploy

$ kubectl apply -f deploy/k8s/prime-generator.yml
$ kubectl apply -f deploy/k8s/prime-proxy.yml

Test

1. Unit Tests

$ sbt prime-generator/test
$ sbt prime-proxy/test
$ sbt test

2. Integration Tests

The end-to-end integration tests are available under prime-proxy/src/it.

$ sbt it:test

Note: While running end to end integration tests make sure to export minikube ip address as environment variable PRIME_PROXY_INTERFACE as shown below:

$ export PRIME_PROXY_INTERFACE=$(minikube ip)

Usage

The prime number generator service is available over following REST APIs.

1. Comma-Separated Stream

The following API returns a stream of comma-separated prime numbers up until a given number.

$ curl $(minikube ip)/prime/23

Note: This is achieved by making use of source streaming support in akka http. See docs. The implementation makes use of custom CsvEntityStreamingSupport.


2. Comma-Separated Seq

The following API returns a string of comma-separated list of prime numbers up until a given number.

$ curl $(minikube ip)/prime/23/seq

Note: There is a hard-limit of 10000 prime numbers is set to avoid OOM.


3. Newline-Separated Stream

The following API returns a stream of prime numbers up until a given number separated by new line.

$ curl $(minikube ip)/prime/23/csv-stream

Note: This is achieved by making use of source streaming support in akka http. See docs. The implementation makes use of default CsvEntityStreamingSupport.


4. SeverSentEvents

An alternative API returns prime numbers as SSE events. There is no hard limit set for this API.

$ curl $(minikube ip)/prime/23/sse

prime-grpc-scala-akka's People

Watchers

 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.