Coder Social home page Coder Social logo

scala-zio-example's Introduction

ScalaZioExample project

Prerequisites

  • sbt
  • Docker
  • docker-compose v2 or higher (Note for macOS: enable Use Docker Compose V2 in Docker Preferences)
  • OpenJDK 11 or above

Setting up

Scalafmt Editor support

Usage

  • Start MySQL in docker container

    Note: flags and options mean:

    • use detached mode
    • wait for all containers to be healthy
    • remove volumes on exit
    docker compose up -Vd --wait mysql
  • Fill db by demo data

    sbt dev "scalaZioExample/runMain org.organization.utils.DemoDb"
  • Run

    sbt dev scalaZioExample/run
  • Run in live reload mode

    sbt dev ~scalaZioExample/reStart
  • When done, remove docker containers, networks and volumes

    docker compose down -v
  • Clean build artifacts and recompile (just in case)

    sbt clean compile
  • Run tests

    sbt test
  • Check for dependency updates (just in case)

      sbt dependencyUpdates

Swagger-UI

Go to http://localhost:8080/docs

Scalafix

  • sbt scalafix โ€“ run linter, check all files, fail on warnings

Tpolecat

There are several modes: dev, ci, release. In dev mode "fatal warnings" are disabled, so you will be able to see warnings, but they won't prevent code from compiling.

  • You can change tpolecat plugin mode in sbt interactively, e.g: sbt ci or sbt dev
  • You can prepend your commands with mode, e.g: sbt ci test or sbt dev test
  • You can set mode via env variable, e.g: SBT_TPOLECAT_DEV=true sbt compile, SBT_TPOLECAT_CI=true sbt compile, or SBT_TPOLECAT_RELEASE=true sbt compile

Migrating to ZIO2

  • Apply the Zio2Upgrade scalafix rule, as described in the migration guide
  • Update dependencies
    • Bump versions on core zio dependencies (zio, zio-streams, zio-test)
    • Remove pins on dependencies which were pinned to prevent a transitive dependency on ZIO2
    • For other ZIO libraries, check their respective docs for a way to correctly add a version with ZIO2 support. Some require you to specify a different organization name or artefact ID:
      • "io.d11" % "zhttp_2.13" -> "dev.zio" %% "zio-http"
      • "com.softwaremill.sttp.tapir" %% "tapir-zio1-http-server" -> "com.softwaremill.sttp.tapir" %% "tapir-zio-http-server"
      • "io.github.scottweaver" %% "zio-testcontainers-mysql" -> "io.github.scottweaver" %% "zio-2-0-testcontainers-mysql"
  • Fix the remaining compilation errors referring to the migration guide.
  • See PR with all the changes listed above

Additional resources

Setting up debugger in Intellij IDEA

scala-zio-example's People

Contributors

artogai avatar codeleventh avatar kolebakin avatar komxxme avatar ksurmel avatar scala-steward avatar vkfisher avatar vladimirlogachev avatar

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.