Skip to content

Rajeshwari-Rudra/scala-big-data-topics

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scala-big-data-topics

Manage a list of big data topics using Scala, Akka, and Akka-HTTP

Links

Prerequisities

  • OpenJDK (8 or higher)
  • sbt (current)
  • (Optional, if Windows) Chocolatey package manager
choco install openjdk -y
choco install sbt -y
choco upgrade sbt -y
choco list --local
refreshenv
sbt --version
sbt scalaVersion

Creating From Scratch

Initialize a new repo

  1. In GitHub, add a new repo
  2. Add a default README.md
  3. (Optional) Add License
  4. Add a .gitignore using Scala template
  5. Clone down to your machine

Create standard Scala project

  1. Add build.sbt
  2. Add project\build.properties
  3. Add project\plugins.sbt
  4. Add src\main\scala\Main.scala
  5. Add src\test\scala\MainSpec.scala
  6. Add src\main\resources\application.conf
  7. Add src\main\resources\logback.xml
  8. Add src\test\resources\application-test.conf

Add VS Code extesions:

  • Scala Syntax (official)
  • Scala (sbt) by LightBend

Add dependencies and static analysis

  1. Add dependencies to build.sbt
  2. Add sbt.version to project/build.properties
  3. In project/plugins.sbt add Scalastyle
  4. Open PowerShell as Admin and run sbt scalastyleGenerateConfig to create config file
  5. Edit scalastyle-config.xml as desired (e.g. file header)

Create the first route in Main.scala

  1. Complete src/main/scala/Main.scala
  2. Open PowerShell as Admin and run sbt scalastyle
  3. Run sbt run

Create the first test in MainSpec.scala

  1. Complete src/test/scala/MainSpec.scala
  2. Open PowerShell as Admin and run sbt scalastyle
  3. Run sbt test

Publish with Heroku

Login to Heroku and create an app. Connect it to your GitHub repo. Enable automatic deployment.

In this repo:

  1. Add Procfile with web path
  2. Add system.properties with java.runtime.version=1.8
  3. Update project/plugins.sbt with sbt and sbt-native-packager
  4. Update build.sbt with .enablePlugins(JavaAppPackaging)
  5. Add scala.util.Properties to Main.scala
  6. Update Main port to use Heroku PORT if available, otherwise development port
  7. Open PowerShell as Admin and run sbt compile stage

Check Endpoints

Open Git Bash and post some data:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"name":"Lexie","age":3, "countryOfResidence": "Finland"}' \
  https://scala-big-data-topics.herokuapp.com/users

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"name":"Abbie","age":19, "countryOfResidence": "Norway"}' \
  https://scala-big-data-topics.herokuapp.com/users

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"name":"Scala","value":1000, "category": "Languages"}' \
  https://scala-big-data-topics.herokuapp.com/topics

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"name":"Python","value":1000, "category": "Languages"}' \
  https://scala-big-data-topics.herokuapp.com/topics

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"name":"JavaScript","value":600, "category": "Languages"}' \
  https://scala-big-data-topics.herokuapp.com/topics

Resources

  1. sbt
  2. Akka
  3. Akka docs
  4. akkahttp-quickstart
  5. ScalaTest
  6. Scala on Command Line
  7. Akka HTTP Quickstart
  8. Scalastyle
  9. Logging
  10. StackOverflow - multiple routes
  11. Scastie formatter
  12. Deploy to Heroku

About

Manage a list of big data topics using Scala, Akka, and HTTP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Scala 100.0%