Skip to content

Commit

Permalink
wip - migrate to play 3.0 & use pekko
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinovega committed Nov 9, 2023
1 parent 1f344bc commit 41c1267
Show file tree
Hide file tree
Showing 55 changed files with 159 additions and 175 deletions.
2 changes: 1 addition & 1 deletion daikoku/app/actions/actions.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.actions

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import cats.implicits.catsSyntaxOptionId
import fr.maif.otoroshi.daikoku.domain.TeamPermission.{Administrator, ApiEditor}
import fr.maif.otoroshi.daikoku.domain._
Expand Down
16 changes: 8 additions & 8 deletions daikoku/app/audit/audit.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package fr.maif.otoroshi.daikoku.audit

import akka.Done
import akka.actor.{Actor, ActorSystem, PoisonPill, Props, Terminated}
import akka.http.scaladsl.util.FastFuture
import akka.http.scaladsl.util.FastFuture._
import akka.kafka.ProducerSettings
import akka.stream.scaladsl.{Keep, Sink, Source}
import akka.stream.{Materializer, OverflowStrategy, QueueOfferResult}
import org.apache.pekko.Done
import org.apache.pekko.actor.{Actor, ActorSystem, PoisonPill, Props, Terminated}
import org.apache.pekko.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture._
import org.apache.pekko.stream.scaladsl.{Keep, Sink, Source}
import org.apache.pekko.stream.{Materializer, OverflowStrategy, QueueOfferResult}
import cats.data.EitherT
import controllers.AppError
import fr.maif.otoroshi.daikoku.audit.config.{ElasticAnalyticsConfig, Webhook}
Expand All @@ -19,6 +18,7 @@ import org.apache.kafka.clients.producer.{Callback, Producer, ProducerRecord, Re
import org.apache.kafka.common.config.SslConfigs
import org.apache.kafka.common.config.internals.BrokerSecurityConfigs
import org.apache.kafka.common.serialization.{ByteArraySerializer, StringSerializer}
import org.apache.pekko.kafka.ProducerSettings
import org.joda.time.DateTime
import org.joda.time.format.ISODateTimeFormat
import play.api.Logger
Expand Down Expand Up @@ -188,7 +188,7 @@ case class TenantAuditEvent(evt: AuditEvent,
"_id" -> IdGenerator.token(32),
"@type" -> theType,
"@id" -> env.snowflakeGenerator.nextIdStr(),
"@timestamp" -> play.api.libs.json.JodaWrites.JodaDateTimeNumberWrites
"@timestamp" -> json.DateTimeFormat
.writes(DateTime.now()),
"@tenantId" -> tenant.id.value,
"@userId" -> user.id.value,
Expand Down
8 changes: 4 additions & 4 deletions daikoku/app/controllers/AdminApiController.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.util.FastFuture
import akka.stream.Materializer
import akka.stream.scaladsl.Source
import akka.util.ByteString
import org.apache.pekko.http.scaladsl.util.FastFuture
import org.apache.pekko.stream.Materializer
import org.apache.pekko.stream.scaladsl.Source
import org.apache.pekko.util.ByteString
import cats.implicits._
import fr.maif.otoroshi.daikoku.actions.{DaikokuAction, DaikokuActionContext}
import fr.maif.otoroshi.daikoku.audit.AuditTrailEvent
Expand Down
10 changes: 5 additions & 5 deletions daikoku/app/controllers/ApiController.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.NotUsed
import akka.http.scaladsl.util.FastFuture
import akka.stream.Materializer
import akka.stream.scaladsl.{Flow, JsonFraming, Sink, Source}
import akka.util.ByteString
import org.apache.pekko.NotUsed
import org.apache.pekko.http.scaladsl.util.FastFuture
import org.apache.pekko.stream.Materializer
import org.apache.pekko.stream.scaladsl.{Flow, JsonFraming, Sink, Source}
import org.apache.pekko.util.ByteString
import cats.Id
import cats.data.EitherT
import cats.implicits.{catsSyntaxOptionId, toTraverseOps}
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/controllers/AppError.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package controllers

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import controllers.AppError.toJson
import play.api.libs.json.{JsObject, Json}
import play.api.mvc
Expand Down
21 changes: 6 additions & 15 deletions daikoku/app/controllers/AssetsController.scala
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.util.FastFuture
import akka.stream.alpakka.s3.ObjectMetadata
import akka.stream.scaladsl.Source
import akka.util.ByteString
import fr.maif.otoroshi.daikoku.actions.{
DaikokuAction,
DaikokuActionMaybeWithGuest,
DaikokuTenantAction
}
import org.apache.pekko.http.scaladsl.util.FastFuture
import org.apache.pekko.stream.scaladsl.Source
import org.apache.pekko.util.ByteString
import fr.maif.otoroshi.daikoku.actions.{DaikokuAction, DaikokuActionMaybeWithGuest, DaikokuTenantAction}
import fr.maif.otoroshi.daikoku.audit.AuditTrailEvent
import fr.maif.otoroshi.daikoku.ctrls.authorizations.async._
import fr.maif.otoroshi.daikoku.domain.AssetId
import fr.maif.otoroshi.daikoku.env.Env
import fr.maif.otoroshi.daikoku.logger.AppLogger
import fr.maif.otoroshi.daikoku.utils.IdGenerator
import org.apache.pekko.stream.connectors.s3.ObjectMetadata
import play.api.http.HttpEntity
import play.api.libs.json.{JsArray, Json}
import play.api.libs.streams.Accumulator
import play.api.mvc.{
AbstractController,
Action,
BodyParser,
ControllerComponents
}
import play.api.mvc.{AbstractController, Action, BodyParser, ControllerComponents}

import scala.concurrent.ExecutionContext
import scala.concurrent.duration.DurationInt
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/controllers/ConsumptionController.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import controllers.AppError
import fr.maif.otoroshi.daikoku.actions.DaikokuAction
import fr.maif.otoroshi.daikoku.audit.AuditTrailEvent
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/controllers/HomeController.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import com.github.blemale.scaffeine.{Cache, Scaffeine}
import com.nimbusds.jose.util.StandardCharset
import daikoku.BuildInfo
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/controllers/JobsController.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import fr.maif.otoroshi.daikoku.env.Env
import fr.maif.otoroshi.daikoku.utils.OtoroshiClient
import jobs.{ApiKeyStatsJob, AuditTrailPurgeJob, OtoroshiVerifierJob}
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/controllers/LoginController.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import com.eatthepath.otp.TimeBasedOneTimePasswordGenerator
import fr.maif.otoroshi.daikoku.actions.{DaikokuAction, DaikokuActionMaybeWithGuest, DaikokuTenantAction, DaikokuTenantActionContext}
import fr.maif.otoroshi.daikoku.audit.{AuditTrailEvent, AuthorizationLevel}
Expand Down
20 changes: 10 additions & 10 deletions daikoku/app/controllers/MessageController.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.actor.{ActorRef, PoisonPill, Props}
import akka.http.scaladsl.util.FastFuture
import akka.pattern.ask
import akka.stream.scaladsl.Source
import akka.stream.{CompletionStrategy, OverflowStrategy}
import akka.util.Timeout
import org.apache.pekko.actor.{ActorRef, PoisonPill, Props}
import org.apache.pekko.http.scaladsl.util.FastFuture
import org.apache.pekko.pattern.ask
import org.apache.pekko.stream.scaladsl.Source
import org.apache.pekko.stream.{CompletionStrategy, OverflowStrategy}
import org.apache.pekko.util.Timeout
import fr.maif.otoroshi.daikoku.actions.DaikokuAction
import fr.maif.otoroshi.daikoku.audit.AuditTrailEvent
import fr.maif.otoroshi.daikoku.ctrls.authorizations.async.{PublicUserAccess, TenantAdminOnly}
Expand Down Expand Up @@ -172,12 +172,12 @@ class MessageController(DaikokuAction: DaikokuAction,
PublicUserAccess(AuditTrailEvent("@{user.name} has received his messages"))(
ctx) {
val completionMatcher: PartialFunction[Any, CompletionStrategy] = {
case akka.actor.Status.Success(s: CompletionStrategy) => s
case akka.actor.Status.Success(_) => CompletionStrategy.draining
case akka.actor.Status.Success => CompletionStrategy.draining
case org.apache.pekko.actor.Status.Success(s: CompletionStrategy) => s
case org.apache.pekko.actor.Status.Success(_) => CompletionStrategy.draining
case org.apache.pekko.actor.Status.Success => CompletionStrategy.draining
}
val failureMatcher: PartialFunction[Any, Throwable] = {
case akka.actor.Status.Failure(cause) => cause
case org.apache.pekko.actor.Status.Failure(cause) => cause
}

val source: Source[JsValue, ActorRef] = Source
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/controllers/MockController.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import cats.implicits.catsSyntaxOptionId
import fr.maif.otoroshi.daikoku.actions.DaikokuAction
import fr.maif.otoroshi.daikoku.domain.TeamPermission._
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/controllers/NotificationController.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import cats.data.EitherT
import controllers.AppError
import controllers.AppError._
Expand Down
8 changes: 4 additions & 4 deletions daikoku/app/controllers/OtoroshiSettingsController.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.model.Uri
import akka.http.scaladsl.util.FastFuture
import akka.stream.scaladsl.Source
import akka.util.ByteString
import org.apache.pekko.http.scaladsl.model.Uri
import org.apache.pekko.http.scaladsl.util.FastFuture
import org.apache.pekko.stream.scaladsl.Source
import org.apache.pekko.util.ByteString
import cats.data.EitherT
import cats.implicits.catsSyntaxOptionId
import com.google.common.base.Charsets
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/controllers/PaymentClient.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import cats.data.{EitherT, OptionT}
import cats.implicits.catsSyntaxOptionId
import controllers.AppError
Expand Down
6 changes: 3 additions & 3 deletions daikoku/app/controllers/TeamController.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.util.FastFuture
import akka.stream.Materializer
import akka.stream.scaladsl.{Sink, Source}
import org.apache.pekko.http.scaladsl.util.FastFuture
import org.apache.pekko.stream.Materializer
import org.apache.pekko.stream.scaladsl.{Sink, Source}
import cats.data.EitherT
import cats.implicits.catsSyntaxOptionId
import controllers.AppError
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/controllers/TenantController.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import cats.data.EitherT
import cats.implicits.catsSyntaxOptionId
import com.nimbusds.jose.jwk.KeyType
Expand Down
4 changes: 2 additions & 2 deletions daikoku/app/controllers/TranslationController.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.util.FastFuture
import akka.stream.Materializer
import org.apache.pekko.http.scaladsl.util.FastFuture
import org.apache.pekko.stream.Materializer
import controllers.AppError
import controllers.AppError.TranslationNotFound
import fr.maif.otoroshi.daikoku.actions.{DaikokuAction, DaikokuActionMaybeWithGuest, DaikokuActionMaybeWithoutUser}
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/controllers/UsersController.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import com.eatthepath.otp.TimeBasedOneTimePasswordGenerator
import fr.maif.otoroshi.daikoku.actions.{DaikokuAction, DaikokuActionMaybeWithGuest}
import fr.maif.otoroshi.daikoku.audit.AuditTrailEvent
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/controllers/authorizations.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.ctrls

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import controllers.AppError
import controllers.AppError.{ForbiddenAction, TeamForbidden, TeamNotFound, Unauthorized}
import fr.maif.otoroshi.daikoku.actions.DaikokuActionContext
Expand Down
4 changes: 2 additions & 2 deletions daikoku/app/daikoku.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.maif.otoroshi.daikoku

import akka.http.scaladsl.util.FastFuture
import akka.stream.Materializer
import org.apache.pekko.http.scaladsl.util.FastFuture
import org.apache.pekko.stream.Materializer
import com.softwaremill.macwire._
import controllers.{Assets, AssetsComponents}
import fr.maif.otoroshi.daikoku.actions.{
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/domain/CommonServices.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.domain

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import cats.implicits.catsSyntaxOptionId
import controllers.AppError
import fr.maif.otoroshi.daikoku.actions.DaikokuActionContext
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/domain/SchemaDefinition.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.domain

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import cats.data.EitherT
import controllers.AppError
import fr.maif.otoroshi.daikoku.actions.DaikokuActionContext
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/domain/apiEntities.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.domain

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import cats.data.EitherT
import cats.syntax.option._
import controllers.AppError
Expand Down
6 changes: 2 additions & 4 deletions daikoku/app/domain/json.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,12 @@ object json {
val DateTimeFormat = new Format[DateTime] {
override def reads(json: JsValue) =
Try {
val longDate: Long =
((json \ "$long").asOpt[Long]).getOrElse(json.as[Long])
JsSuccess(new DateTime(longDate))
JsSuccess(new DateTime(json.as[Long]))
} recover {
case e => JsError(e.getMessage)
} get

override def writes(o: DateTime) = JsNumber(o.toDate.getTime)
override def writes(o: DateTime) = JsNumber(o.getMillis)
}

val OtoroshiSettingsFormat = new Format[OtoroshiSettings] {
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/domain/tenantEntities.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.maif.otoroshi.daikoku.domain

import akka.http.scaladsl.util.FastFuture
import org.apache.pekko.http.scaladsl.util.FastFuture
import cats.implicits.catsSyntaxOptionId
import com.github.jknack.handlebars.{Context, Handlebars, Options}
import controllers.AppError
Expand Down
8 changes: 4 additions & 4 deletions daikoku/app/env/env.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package fr.maif.otoroshi.daikoku.env

import akka.actor.{ActorRef, ActorSystem, PoisonPill}
import akka.http.scaladsl.util.FastFuture
import akka.stream.Materializer
import akka.stream.scaladsl.{FileIO, Keep, Sink, Source}
import org.apache.pekko.actor.{ActorRef, ActorSystem, PoisonPill}
import org.apache.pekko.http.scaladsl.util.FastFuture
import org.apache.pekko.stream.Materializer
import org.apache.pekko.stream.scaladsl.{FileIO, Keep, Sink, Source}
import cats.implicits.catsSyntaxOptionId
import com.auth0.jwt.algorithms.Algorithm
import com.auth0.jwt.{JWT, JWTVerifier}
Expand Down
8 changes: 4 additions & 4 deletions daikoku/app/env/evolutions.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package fr.maif.otoroshi.daikoku.env

import akka.Done
import akka.http.scaladsl.util.FastFuture
import akka.stream.Materializer
import akka.stream.scaladsl.{Sink, Source}
import org.apache.pekko.Done
import org.apache.pekko.http.scaladsl.util.FastFuture
import org.apache.pekko.stream.Materializer
import org.apache.pekko.stream.scaladsl.{Sink, Source}
import cats.data.OptionT
import cats.implicits.catsSyntaxOptionId
import fr.maif.otoroshi.daikoku.domain._
Expand Down
10 changes: 5 additions & 5 deletions daikoku/app/jobs/ApiKeyStatsJob.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package jobs

import akka.actor.Cancellable
import akka.http.scaladsl.util.FastFuture
import akka.stream.Materializer
import akka.stream.scaladsl.{Flow, Sink, Source}
import akka.{Done, NotUsed}
import org.apache.pekko.actor.Cancellable
import org.apache.pekko.http.scaladsl.util.FastFuture
import org.apache.pekko.stream.Materializer
import org.apache.pekko.stream.scaladsl.{Flow, Sink, Source}
import org.apache.pekko.{Done, NotUsed}
import cats.data.OptionT
import cats.implicits.catsSyntaxOptionId
import fr.maif.otoroshi.daikoku.domain.BillingTimeUnit.{Day, Hour, Month, Year}
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/jobs/AuditTrailPurgeJob.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package jobs

import akka.actor.Cancellable
import org.apache.pekko.actor.Cancellable
import fr.maif.otoroshi.daikoku.env.Env
import org.joda.time.DateTime
import play.api.Logger
Expand Down
6 changes: 3 additions & 3 deletions daikoku/app/jobs/OtoroshiVerifierJob.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package jobs

import akka.Done
import akka.actor.Cancellable
import akka.stream.scaladsl.{Sink, Source}
import org.apache.pekko.Done
import org.apache.pekko.actor.Cancellable
import org.apache.pekko.stream.scaladsl.{Sink, Source}
import cats.data.EitherT
import cats.syntax.option._
import controllers.AppError
Expand Down
Loading

0 comments on commit 41c1267

Please sign in to comment.