Skip to content

Commit

Permalink
feat: Enable compaction after project erasure, with feature flag (DEV…
Browse files Browse the repository at this point in the history
  • Loading branch information
siers authored Oct 4, 2024
1 parent 382826f commit 4718cc8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions webapi/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@ app {
allow-erase-projects = false
allow-erase-projects = ${?ALLOW_ERASE_PROJECTS}

trigger-compaction-after-project-erasure = false
trigger-compaction-after-project-erasure = ${?TRIGGER_COMPACTION_AFTER_PROJECT_ERASURE}

disable-last-modification-date-check = false
disable-last-modification-date-check = ${?DISABLE_LAST_MODIFICATION_DATE_CHECK}
}
Expand Down
6 changes: 4 additions & 2 deletions webapi/src/main/scala/org/knora/webapi/config/AppConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ final case class InstrumentationServerConfig(
final case class Features(
allowEraseProjects: Boolean,
disableLastModificationDateCheck: Boolean,
triggerCompactionAfterProjectErasure: Boolean,
)

object AppConfig {
Expand All @@ -195,8 +196,9 @@ object AppConfig {

private def logFeaturesEnabled(c: AppConfig) = {
val features = List(
"ALLOW_ERASE_PROJECTS" -> c.features.allowEraseProjects,
"DISABLE_LAST_MODIFICATION_DATE_CHECK" -> c.features.disableLastModificationDateCheck,
"ALLOW_ERASE_PROJECTS" -> c.features.allowEraseProjects,
"DISABLE_LAST_MODIFICATION_DATE_CHECK" -> c.features.disableLastModificationDateCheck,
"TRIGGER_COMPACTION_AFTER_PROJECT_ERASURE" -> c.features.triggerCompactionAfterProjectErasure,
).collect { case (feature, enabled) if enabled => feature }
ZIO.logInfo(s"Features enabled: ${features.mkString(", ")}").when(features.nonEmpty)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import org.knora.webapi.slice.admin.domain.service.UserService
import org.knora.webapi.slice.common.Value.StringValue
import org.knora.webapi.slice.common.api.AuthorizationRestService
import org.knora.webapi.slice.common.api.KnoraResponseRenderer
import org.knora.webapi.store.triplestore.api.TriplestoreService

final case class ProjectRestService(
format: KnoraResponseRenderer,
Expand All @@ -48,6 +49,7 @@ final case class ProjectRestService(
userService: UserService,
auth: AuthorizationRestService,
features: Features,
triplestore: TriplestoreService,
) {

/**
Expand Down Expand Up @@ -144,6 +146,7 @@ final case class ProjectRestService(
_ <- ZIO.logInfo(s"${user.userIri} erases project $shortcode")
_ <- projectEraseService.eraseProject(project, keepAssets)
external <- format.toExternal(ProjectOperationResponseADM(internal))
_ <- ZIO.when(features.triggerCompactionAfterProjectErasure)(triplestore.compact())
} yield external

/**
Expand Down

0 comments on commit 4718cc8

Please sign in to comment.