Skip to content

Commit

Permalink
chore: convert ValueEntity codegen to new scheme (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrudolph committed Oct 19, 2021
1 parent fdb6822 commit 02d6592
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ object ActionServiceSourceGenerator {
Seq(abstractAction(service), actionRouter(service), actionProvider(service))

private[codegen] def actionSource(service: ModelBuilder.ActionService): File = {
import Types._
import Types.{ Source, NotUsed }
import Types.Action._

val className = service.className

Expand Down Expand Up @@ -100,7 +101,8 @@ object ActionServiceSourceGenerator {
}

private[codegen] def abstractAction(service: ModelBuilder.ActionService): File = {
import Types._
import Types.{ Source, NotUsed }
import Types.Action._

val methods = service.commands.map { cmd =>
val methodName = cmd.name
Expand Down Expand Up @@ -141,7 +143,8 @@ object ActionServiceSourceGenerator {
}

private[codegen] def actionRouter(service: ModelBuilder.ActionService): File = {
import Types._
import Types.{ Source, NotUsed }
import Types.Action._

val unaryCases = service.commands.filter(_.isUnary).map { cmd =>
val methodName = cmd.name
Expand Down Expand Up @@ -223,7 +226,8 @@ object ActionServiceSourceGenerator {
}

private[codegen] def actionProvider(service: ModelBuilder.ActionService): File = {
import Types._
import Types.{ Descriptors, ImmutableSeq }
import Types.Action._

generate(
service.fqn.parent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object EventSourcedEntitySourceGenerator {
private[codegen] def abstractEntity(
eventSourcedEntity: ModelBuilder.EventSourcedEntity,
service: ModelBuilder.EntityService): File = {
import Types._
import Types.EventSourcedEntity._
val abstractEntityName = eventSourcedEntity.abstractEntityName

val stateType = eventSourcedEntity.state.fqn
Expand Down Expand Up @@ -78,7 +78,7 @@ object EventSourcedEntitySourceGenerator {
private[codegen] def handler(
eventSourcedEntity: ModelBuilder.EventSourcedEntity,
service: ModelBuilder.EntityService): File = {
import Types._
import Types.EventSourcedEntity._

val stateType = eventSourcedEntity.state.fqn
val eventSourcedEntityName = eventSourcedEntity.fqn
Expand Down Expand Up @@ -126,7 +126,8 @@ object EventSourcedEntitySourceGenerator {
}

def provider(entity: ModelBuilder.EventSourcedEntity, service: ModelBuilder.EntityService): File = {
import Types._
import Types.{ ImmutableSeq, Descriptors }
import Types.EventSourcedEntity._
val className = entity.providerName

val descriptors =
Expand Down Expand Up @@ -166,7 +167,7 @@ object EventSourcedEntitySourceGenerator {
def generateImplementationSkeleton(
eventSourcedEntity: ModelBuilder.EventSourcedEntity,
service: ModelBuilder.EntityService): File = {
import Types._
import Types.EventSourcedEntity._

val eventHandlers =
eventSourcedEntity.events.map { event =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,41 @@ package com.akkaserverless.codegen.scalasdk.impl
import com.lightbend.akkasls.codegen.FullyQualifiedName

object Types {
val EventSourcedEntity = FQN("com.akkaserverless.scalasdk.eventsourcedentity.EventSourcedEntity")
val EventSourcedEntityProvider = FQN("com.akkaserverless.scalasdk.eventsourcedentity.EventSourcedEntityProvider")
val EventSourcedEntityOptions = FQN("com.akkaserverless.scalasdk.eventsourcedentity.EventSourcedEntityOptions")
val EventSourcedEntityContext = FQN("com.akkaserverless.scalasdk.eventsourcedentity.EventSourcedEntityContext")

val CommandContext = FQN("com.akkaserverless.scalasdk.eventsourcedentity.CommandContext")
val EventSourcedEntityRouter = FQN("com.akkaserverless.scalasdk.impl.eventsourcedentity.EventSourcedEntityRouter")

val CommandHandlerNotFound = FQN(
"com.akkaserverless.javasdk.impl.eventsourcedentity.EventSourcedEntityRouter.CommandHandlerNotFound")
val EventHandlerNotFound = FQN(
"com.akkaserverless.javasdk.impl.eventsourcedentity.EventSourcedEntityRouter.EventHandlerNotFound")

val Action = FQN("com.akkaserverless.scalasdk.action.Action")
val ActionCreationContext = FQN("com.akkaserverless.scalasdk.action.ActionCreationContext")
val ActionOptions = FQN("com.akkaserverless.scalasdk.action.ActionOptions")
val ActionProvider = FQN("com.akkaserverless.scalasdk.action.ActionProvider")
val MessageEnvelope = FQN("com.akkaserverless.scalasdk.action.MessageEnvelope")
val ActionRouter = FQN("com.akkaserverless.scalasdk.impl.action.ActionRouter")
val HandlerNotFound = FQN("com.akkaserverless.javasdk.impl.action.ActionRouter.HandlerNotFound")
object Action {
val Action = FQN("com.akkaserverless.scalasdk.action.Action")
val ActionCreationContext = FQN("com.akkaserverless.scalasdk.action.ActionCreationContext")
val ActionOptions = FQN("com.akkaserverless.scalasdk.action.ActionOptions")
val ActionProvider = FQN("com.akkaserverless.scalasdk.action.ActionProvider")
val MessageEnvelope = FQN("com.akkaserverless.scalasdk.action.MessageEnvelope")
val ActionRouter = FQN("com.akkaserverless.scalasdk.impl.action.ActionRouter")
val HandlerNotFound = FQN("com.akkaserverless.javasdk.impl.action.ActionRouter.HandlerNotFound")
}

object EventSourcedEntity {
val EventSourcedEntity = FQN("com.akkaserverless.scalasdk.eventsourcedentity.EventSourcedEntity")
val EventSourcedEntityProvider = FQN("com.akkaserverless.scalasdk.eventsourcedentity.EventSourcedEntityProvider")
val EventSourcedEntityOptions = FQN("com.akkaserverless.scalasdk.eventsourcedentity.EventSourcedEntityOptions")
val EventSourcedEntityContext = FQN("com.akkaserverless.scalasdk.eventsourcedentity.EventSourcedEntityContext")

val CommandContext = FQN("com.akkaserverless.scalasdk.eventsourcedentity.CommandContext")
val EventSourcedEntityRouter = FQN("com.akkaserverless.scalasdk.impl.eventsourcedentity.EventSourcedEntityRouter")

val CommandHandlerNotFound = FQN(
"com.akkaserverless.javasdk.impl.eventsourcedentity.EventSourcedEntityRouter.CommandHandlerNotFound")
val EventHandlerNotFound = FQN(
"com.akkaserverless.javasdk.impl.eventsourcedentity.EventSourcedEntityRouter.EventHandlerNotFound")
}

object ValueEntity {
val ValueEntity = FQN("com.akkaserverless.scalasdk.valueentity.ValueEntity")
val CommandContext = FQN("com.akkaserverless.scalasdk.valueentity.CommandContext")
val ValueEntityContext = FQN("com.akkaserverless.scalasdk.valueentity.ValueEntityContext")
val ValueEntityOptions = FQN("com.akkaserverless.scalasdk.valueentity.ValueEntityOptions")
val ValueEntityProvider = FQN("com.akkaserverless.scalasdk.valueentity.ValueEntityProvider")
val ValueEntityRouter = FQN("com.akkaserverless.scalasdk.impl.valueentity.ValueEntityRouter")
val CommandHandlerNotFound = FQN(
"com.akkaserverless.javasdk.impl.valueentity.ValueEntityRouter.CommandHandlerNotFound")
}

val Source = FQN("akka.stream.scaladsl.Source")
val NotUsed = FQN("akka.NotUsed")
Expand Down

0 comments on commit 02d6592

Please sign in to comment.