Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(IIIFService): zio-fying iiif service (DEV-801) #2044

Merged
merged 50 commits into from May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
29ce54b
refactor(IIIFService): IIIFService and config
subotic Apr 13, 2022
e35cbb1
Update ManagersWithMockedSipi.scala
subotic Apr 13, 2022
5cfa753
Merge branch 'main' into wip/DEV-801-zio-fying-iiif-service
subotic Apr 13, 2022
1f1d6bc
Merge branch 'main' into wip/DEV-801-zio-fying-iiif-service
subotic Apr 14, 2022
755d62a
refactor(IIIFService): use TestManagersWithMockedSipi for tests needi…
subotic Apr 14, 2022
ea9a4dd
build(CI): change Java to Temurin JDK 17
subotic Apr 14, 2022
2a18748
refactor(IIIFService): use TestManagersWithAllTestContainers (ongoing)
subotic Apr 14, 2022
bed2eff
refactor(IIIFService): use TestManagersWithAllTestContainers
subotic Apr 15, 2022
76b92cb
refactor(IIIFService): use sipi test client (ongoing)
subotic Apr 16, 2022
5d4c3ce
refactor(IIIFService): use test client (ongoing)
subotic Apr 18, 2022
09a07b9
refactor(IIIFService): use test client
subotic Apr 18, 2022
8a90c9c
refactor(IIIFService): fix tests
subotic Apr 18, 2022
e9cf31e
refactor(IIIFService): fix tests
subotic Apr 19, 2022
867e4f3
refactor(IIIFService): fix shacl tests
subotic Apr 19, 2022
bdc03b9
refactor(IIIFService): fix integration specs (reverting to original i…
subotic Apr 19, 2022
d2fa994
refactor(IIIFService): fix tests on CI (trying)
subotic Apr 19, 2022
60bf122
Update TestClientService.scala
subotic Apr 19, 2022
e292672
remove unused tests
subotic Apr 19, 2022
c54c77d
refactor(IIIFService): optimize logging
subotic Apr 19, 2022
180c95e
refactor(IIIFService): raise timeout in TestClient
subotic Apr 19, 2022
f842570
refactor(IIIFService): fix error handling
subotic Apr 20, 2022
86b658a
refactor(IIIFService): tune down logging
subotic Apr 20, 2022
7aea3de
add scalafmt plugin
subotic Apr 23, 2022
63461fa
add better error handling at the edge
subotic Apr 23, 2022
76b3434
add automatic format checking
subotic Apr 23, 2022
f390494
add automatic format checking
subotic Apr 23, 2022
6053b17
add automatic format checking
subotic Apr 23, 2022
499c3f2
Merge branch 'main' into wip/DEV-801-zio-fying-iiif-service
subotic Apr 26, 2022
6a5d77e
format more files
subotic Apr 26, 2022
a16293f
add ADR
subotic Apr 28, 2022
c44718c
Merge branch 'main' into wip/DEV-801-zio-fying-iiif-service
subotic Apr 28, 2022
f0e740f
Update webapi/src/main/scala/org/knora/webapi/config/AppConfig.scala
subotic May 3, 2022
f8d2f88
Update webapi/src/test/scala/org/knora/webapi/testcontainers/SipiTest…
subotic May 3, 2022
937df12
Update webapi/src/test/scala/org/knora/webapi/testservices/TestClient…
subotic May 3, 2022
245b02a
Update webapi/src/test/scala/org/knora/webapi/testservices/TestClient…
subotic May 3, 2022
5de2b21
Update webapi/src/test/scala/org/knora/webapi/testservices/TestClient…
subotic May 3, 2022
5d064cc
Update webapi/src/test/scala/org/knora/webapi/testservices/TestClient…
subotic May 3, 2022
ca5bd78
add review fixes
subotic May 3, 2022
9a2a8d4
Merge branch 'wip/DEV-801-zio-fying-iiif-service' of github.com:dasch…
subotic May 3, 2022
024eec0
add review fixes
subotic May 3, 2022
8243aa1
fix formatting
subotic May 3, 2022
ce5929b
Update .gitignore
subotic May 3, 2022
8114547
Update webapi/src/main/scala/org/knora/webapi/store/iiif/IIIFServiceM…
subotic May 4, 2022
2c76c60
organize imports
subotic May 4, 2022
54bede5
Merge branch 'wip/DEV-801-zio-fying-iiif-service' of github.com:dasch…
subotic May 4, 2022
aff409c
fix formatting
subotic May 4, 2022
3663a3d
rename class
subotic May 4, 2022
d74a6a2
fix typos
subotic May 4, 2022
6ffb1e4
add missing type annotations
subotic May 4, 2022
33f37ad
Merge branch 'main' into wip/DEV-801-zio-fying-iiif-service
subotic May 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
76 changes: 55 additions & 21 deletions .github/workflows/main.yml
Expand Up @@ -17,22 +17,17 @@ jobs:
uses: actions/checkout@v1
with:
fetch-depth: 15
- name: Setup JDK
uses: actions/setup-java@v2
with:
distribution: temurin
java-version: 11
- name: get current time
uses: josStorer/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DD
utcOffset: "+02:00"
- name: setup java version
uses: joschi/setup-jdk@v2
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11' # The OpenJDK version to make available on the path
architecture: 'x64' # defaults to 'x64'
distribution: 'temurin'
java-version: '17'
- name: add docker compose v2
run: |
mkdir -p ~/.docker/cli-plugins/
Expand Down Expand Up @@ -69,11 +64,11 @@ jobs:
with:
format: YYYY-MM-DD
utcOffset: "+02:00"
- name: setup java version
uses: joschi/setup-jdk@v2
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11' # The OpenJDK version to make available on the path
architecture: 'x64' # defaults to 'x64'
distribution: 'temurin'
java-version: '17'
- name: add docker compose v2
run: |
mkdir -p ~/.docker/cli-plugins/
Expand Down Expand Up @@ -116,11 +111,11 @@ jobs:
with:
format: YYYY-MM-DD
utcOffset: "+02:00"
- name: setup java version
uses: joschi/setup-jdk@v2
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11' # The OpenJDK version to make available on the path
architecture: 'x64' # defaults to 'x64'
distribution: 'temurin'
java-version: '17'
- name: add docker compose v2
run: |
mkdir -p ~/.docker/cli-plugins/
Expand Down Expand Up @@ -211,11 +206,11 @@ jobs:
with:
format: YYYY-MM-DD
utcOffset: "+02:00"
- name: setup java version
uses: joschi/setup-jdk@v2
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11' # The OpenJDK version to make available on the path
architecture: 'x64' # defaults to 'x64'
distribution: 'temurin'
java-version: '17'
- name: add docker compose v2
run: |
mkdir -p ~/.docker/cli-plugins/
Expand Down Expand Up @@ -287,3 +282,42 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
CUSTOM_DOMAIN: docs-api.dasch.swiss
REQUIREMENTS: docs/requirements.txt

fmtcheck:
name: Check Formating
runs-on: ubuntu-latest
steps:
- name: checkout source
uses: actions/checkout@v1
with:
fetch-depth: 15
- name: get current time
uses: josStorer/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DD
utcOffset: "+02:00"
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: add docker compose v2
run: |
mkdir -p ~/.docker/cli-plugins/
curl -SL https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
chmod +x ~/.docker/cli-plugins/docker-compose
- name: install requirements
run: sudo apt-get install ca-certificates-java expect
- name: Coursier cache
uses: coursier/cache-action@v6
- name: Run fmtcheck
run: make check
- name: Cleanup before cache
shell: bash
run: |
rm -rf "$HOME/.ivy2/local" || true
find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.sbt -name "*.lock" -delete || true
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -46,7 +46,7 @@ sipi/images/originals/1111/*

.idea/
.metals/
metals.sbt
**/metals.sbt

.tmp/

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Expand Up @@ -300,6 +300,10 @@ info: ## print out all variables
@echo "BUILD_TAG: \t\t $(BUILD_TAG)"
@echo "GIT_EMAIL: \t\t $(GIT_EMAIL)"

.PHONY: check
check: # Run code formating check
@sbt "check"

.PHONY: help
help: ## this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
Expand Down
9 changes: 4 additions & 5 deletions build.sbt
Expand Up @@ -49,6 +49,9 @@ lazy val root: Project = Project(id = "root", file("."))
publish / skip := true
)

addCommandAlias("fmt", "all root/scalafmtSbt root/scalafmtAll")
addCommandAlias("check", "all root/scalafmtSbtCheck root/scalafmtCheckAll")

//////////////////////////////////////
// DSP's custom SIPI
//////////////////////////////////////
Expand Down Expand Up @@ -98,7 +101,7 @@ lazy val webApiCommonSettings = Seq(

lazy val webapi: Project = Project(id = "webapi", base = file("webapi"))
.settings(buildSettings)
.enablePlugins(SbtTwirl, JavaAppPackaging, DockerPlugin, GatlingPlugin, JavaAgent, RevolverPlugin, BuildInfoPlugin)
.enablePlugins(SbtTwirl, JavaAppPackaging, DockerPlugin, GatlingPlugin, JavaAgent, BuildInfoPlugin)
.settings(
name := "webapi",
resolvers ++= Seq(
Expand Down Expand Up @@ -133,10 +136,6 @@ lazy val webapi: Project = Project(id = "webapi", base = file("webapi"))
scalacOptions ++= Seq("-feature", "-unchecked", "-deprecation", "-Yresolve-term-conflict:package"),
logLevel := Level.Info,
run / javaOptions := webapiJavaRunOptions,
reStart / javaOptions ++= resolvedJavaAgents.value map { resolved =>
"-javaagent:" + resolved.artifact.absolutePath + resolved.agent.arguments
}, // allows sbt-javaagent to work with sbt-revolver
reStart / javaOptions ++= webapiJavaRunOptions,
javaAgents += Dependencies.aspectjweaver,
fork := true, // run tests in a forked JVM
Test / testForkedParallel := false, // run forked tests in parallel
Expand Down
@@ -0,0 +1,20 @@
# 3. Change IIIF Service Manager and Sipi implementation to zlayer

Date: 2022-04-29

## Status

Accepted

## Context

Both `org.knora.webapi.store.iiif.IIIFServiceManager` and `org.knora.webapi.store.iiif.impl.IIIFServiceSipiImpl`
where implemented as Akka-Actors

## Decision

As part of the move from `Akka` to `ZIO`, it was decided that the `IIIFServiceManager` and the `IIIFServiceSipiImpl` is refactored using ZIO.

## Consequences

The usage from other actors stays the same. The actor messages and responses don't change.
3 changes: 2 additions & 1 deletion dsp-api-main/src/main/scala/dsp/api/main/MainApp.scala
@@ -1,6 +1,7 @@
package dsp.api.main

import dsp.schema.repo.{SchemaRepo, SchemaRepoLive}
import dsp.schema.repo.SchemaRepo
import dsp.schema.repo.SchemaRepoLive
import zio.Console.printLine
import zio._

Expand Down
4 changes: 2 additions & 2 deletions project/Dependencies.scala
Expand Up @@ -33,7 +33,7 @@ object Dependencies {
val zioHttp = "io.d11" %% "zhttp" % ZioHttpVersion
val zioJson = "dev.zio" %% "zio-json" % ZioJsonVersion
val zioPrelude = "dev.zio" %% "zio-prelude" % ZioPreludeVersion
val zioLoggingSlf4j = "dev.zio" %% "zio-logging-slf4j" % ZioLoggingVersion
val zioLogging = "dev.zio" %% "zio-logging" % ZioLoggingVersion
val zioConfig = "dev.zio" %% "zio-config" % ZioConfigVersion
val zioConfigMagnolia = "dev.zio" %% "zio-config-magnolia" % ZioConfigVersion
val zioConfigTypesafe = "dev.zio" %% "zio-config-typesafe" % ZioConfigVersion
Expand Down Expand Up @@ -143,7 +143,7 @@ object Dependencies {
zioConfigTypesafe,
zioHttp,
zioJson,
zioLoggingSlf4j,
zioLogging,
zioPrelude,
zioTest % Test,
zioTestSbt % Test
Expand Down
14 changes: 4 additions & 10 deletions project/plugins.sbt
Expand Up @@ -5,20 +5,17 @@ resolvers ++= Seq(
// please don't remove or merge uncommented to main
addDependencyTreePlugin

// Knora
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.2")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9")
addSbtPlugin("io.kamon" % "sbt-aspectj-runner" % "1.1.1")

// webapi
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.2")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9")
addSbtPlugin("io.kamon" % "sbt-aspectj-runner" % "1.1.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.5.1")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
addSbtPlugin("com.lightbend.sbt" % "sbt-javaagent" % "0.1.5")
addSbtPlugin("io.gatling" % "gatling-sbt" % "2.2.2")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.15")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")

// ad-hoc plugins - uncomment on demenad and keep it commented out in main branch

Expand All @@ -27,6 +24,3 @@ addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")

// https://github.com/cb372/sbt-explicit-dependencies
// addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16")

// https://scalameta.org/scalafmt/docs/installation.html#sbt
// addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
4 changes: 2 additions & 2 deletions sipi/scripts/jwt.lua
Expand Up @@ -26,9 +26,9 @@ function get_knora_token()
end

token_issuer = webapi_hostname .. ':' .. webapi_port
server.log("token_issuer:" .. token_issuer, server.loglevel.LOG_DEBUG)
server.log("token_issuer: " .. token_issuer, server.loglevel.LOG_DEBUG)
if token["iss"] ~= token_issuer then
server.log(token_issuer, server.loglevel.LOG_DEBUG)
server.log("Invalid token issuer: " .. token_issuer .. " . Expected: " .. token["iss"], server.loglevel.LOG_DEBUG)
send_error(401, "Invalid token. The token was not issued by the same server that sent the request.")
return nil
end
Expand Down
2 changes: 1 addition & 1 deletion webapi/src/main/resources/application.conf
Expand Up @@ -296,7 +296,7 @@ app {

shacl {
# The directory that SHACL shapes are loaded from.
shapes-dir = "shacl"
shapes-dir = "../test_data/shacl"
subotic marked this conversation as resolved.
Show resolved Hide resolved
subotic marked this conversation as resolved.
Show resolved Hide resolved
shapes-dir = ${?KNORA_WEBAPI_SHACLE_SHAPES_DIR}
}

Expand Down
Expand Up @@ -5,7 +5,10 @@

package org.knora.webapi

import akka.http.scaladsl.model.{ContentType, HttpCharsets, MediaType, MediaTypes}
import akka.http.scaladsl.model.ContentType
import akka.http.scaladsl.model.HttpCharsets
import akka.http.scaladsl.model.MediaType
import akka.http.scaladsl.model.MediaTypes

/**
* Represents media types supported by the Knora API server for representing RDF data, and provides
Expand Down