From 98e726e482e8e7a976181870e1ee2421582134f2 Mon Sep 17 00:00:00 2001 From: Andrzej Ludwikowski Date: Fri, 13 Dec 2024 14:23:06 +0100 Subject: [PATCH] chore: removing entities and workflows from proto spec (#87) * chore: removing entities and workflows from proto spec * bumping runtime --- .../akka-javasdk-parent/pom.xml | 2 +- .../scala/akka/javasdk/impl/SdkRunner.scala | 60 ++----------------- .../EventSourcedEntityService.scala | 22 ------- .../KeyValueEntityService.scala | 22 ------- .../javasdk/impl/workflow/WorkflowImpl.scala | 17 ------ .../java/pages/event-sourced-entities.adoc | 30 ---------- .../java/pages/key-value-entities.adoc | 22 +------ project/Dependencies.scala | 2 +- .../controller-requests.http | 5 +- samples/key-value-customer-registry/README.md | 34 ----------- 10 files changed, 9 insertions(+), 207 deletions(-) delete mode 100644 akka-javasdk/src/main/scala/akka/javasdk/impl/eventsourcedentity/EventSourcedEntityService.scala delete mode 100644 akka-javasdk/src/main/scala/akka/javasdk/impl/keyvalueentity/KeyValueEntityService.scala diff --git a/akka-javasdk-maven/akka-javasdk-parent/pom.xml b/akka-javasdk-maven/akka-javasdk-parent/pom.xml index 4f4f332f2..18caa0ec5 100644 --- a/akka-javasdk-maven/akka-javasdk-parent/pom.xml +++ b/akka-javasdk-maven/akka-javasdk-parent/pom.xml @@ -38,7 +38,7 @@ 21 - 1.3.0-f5764fe + 1.3.0-03a3a40 UTF-8 false diff --git a/akka-javasdk/src/main/scala/akka/javasdk/impl/SdkRunner.scala b/akka-javasdk/src/main/scala/akka/javasdk/impl/SdkRunner.scala index 1255a713b..bc7650ded 100644 --- a/akka-javasdk/src/main/scala/akka/javasdk/impl/SdkRunner.scala +++ b/akka-javasdk/src/main/scala/akka/javasdk/impl/SdkRunner.scala @@ -46,11 +46,9 @@ import akka.javasdk.impl.Validations.Validation import akka.javasdk.impl.client.ComponentClientImpl import akka.javasdk.impl.consumer.ConsumerImpl import akka.javasdk.impl.eventsourcedentity.EventSourcedEntityImpl -import akka.javasdk.impl.eventsourcedentity.EventSourcedEntityService import akka.javasdk.impl.http.HttpClientProviderImpl import akka.javasdk.impl.http.JwtClaimsImpl import akka.javasdk.impl.keyvalueentity.KeyValueEntityImpl -import akka.javasdk.impl.keyvalueentity.KeyValueEntityService import akka.javasdk.impl.reflection.Reflect import akka.javasdk.impl.reflection.Reflect.Syntax.AnnotatedElementOps import akka.javasdk.impl.serialization.JsonSerializer @@ -60,7 +58,6 @@ import akka.javasdk.impl.timedaction.TimedActionImpl import akka.javasdk.impl.timer.TimerSchedulerImpl import akka.javasdk.impl.view.ViewDescriptorFactory import akka.javasdk.impl.workflow.WorkflowImpl -import akka.javasdk.impl.workflow.WorkflowService import akka.javasdk.keyvalueentity.KeyValueEntity import akka.javasdk.keyvalueentity.KeyValueEntityContext import akka.javasdk.timedaction.TimedAction @@ -319,13 +316,13 @@ private final class Sdk( None } else if (classOf[EventSourcedEntity[_, _]].isAssignableFrom(clz)) { logger.debug(s"Registering EventSourcedEntity [${clz.getName}]") - Some(eventSourcedEntityService(clz.asInstanceOf[Class[EventSourcedEntity[Nothing, Nothing]]])) + None } else if (classOf[Workflow[_]].isAssignableFrom(clz)) { logger.debug(s"Registering Workflow [${clz.getName}]") - Some(workflowService(clz.asInstanceOf[Class[Workflow[Nothing]]])) + None } else if (classOf[KeyValueEntity[_]].isAssignableFrom(clz)) { logger.debug(s"Registering KeyValueEntity [${clz.getName}]") - Some(keyValueEntityService(clz.asInstanceOf[Class[KeyValueEntity[Nothing]]])) + None } else if (Reflect.isView(clz)) { logger.debug(s"Registering View [${clz.getName}]") None // no factory, handled below @@ -555,19 +552,8 @@ private final class Sdk( serviceDescriptor.getFullName -> service } - services.groupBy(_._2.getClass).foreach { - - case (serviceClass, _: Map[String, EventSourcedEntityService[_, _, _]] @unchecked) - if serviceClass == classOf[EventSourcedEntityService[_, _, _]] => - - case (serviceClass, _: Map[String, KeyValueEntityService[_, _]] @unchecked) - if serviceClass == classOf[KeyValueEntityService[_, _]] => - - case (serviceClass, _: Map[String, WorkflowService[_, _]] @unchecked) - if serviceClass == classOf[WorkflowService[_, _]] => - - case (serviceClass, _) => - sys.error(s"Unknown service type: $serviceClass") + services.groupBy(_._2.getClass).foreach { case (serviceClass, _) => + sys.error(s"Unknown service type: $serviceClass") } val serviceSetup: Option[ServiceSetup] = maybeServiceClass match { @@ -644,42 +630,6 @@ private final class Sdk( } } - private def workflowService[S, W <: Workflow[S]](clz: Class[W]): WorkflowService[S, W] = { - new WorkflowService[S, W]( - clz, - serializer, - { context => - - val workflow = wiredInstance(clz) { - sideEffectingComponentInjects(None).orElse { - // remember to update component type API doc and docs if changing the set of injectables - case p if p == classOf[WorkflowContext] => context - } - } - - // FIXME pull this inline setup stuff out of SdkRunner and into some workflow class - val workflowStateType: Class[S] = Reflect.workflowStateType(workflow) - serializer.registerTypeHints(workflowStateType) - - workflow - .definition() - .getSteps - .asScala - .flatMap { case asyncCallStep: Workflow.AsyncCallStep[_, _, _] => - List(asyncCallStep.callInputClass, asyncCallStep.transitionInputClass) - } - .foreach(serializer.registerTypeHints) - - workflow - }) - } - private def eventSourcedEntityService[S, E, ES <: EventSourcedEntity[S, E]]( - clz: Class[ES]): EventSourcedEntityService[S, E, ES] = - EventSourcedEntityService(clz, serializer) - - private def keyValueEntityService[S, VE <: KeyValueEntity[S]](clz: Class[VE]): KeyValueEntityService[S, VE] = - new KeyValueEntityService(clz, serializer) - private def httpEndpointFactory[E](httpEndpointClass: Class[E]): HttpEndpointConstructionContext => E = { (context: HttpEndpointConstructionContext) => lazy val requestContext = new RequestContext { diff --git a/akka-javasdk/src/main/scala/akka/javasdk/impl/eventsourcedentity/EventSourcedEntityService.scala b/akka-javasdk/src/main/scala/akka/javasdk/impl/eventsourcedentity/EventSourcedEntityService.scala deleted file mode 100644 index c577c7f48..000000000 --- a/akka-javasdk/src/main/scala/akka/javasdk/impl/eventsourcedentity/EventSourcedEntityService.scala +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2021-2024 Lightbend Inc. - */ - -package akka.javasdk.impl.eventsourcedentity - -import akka.annotation.InternalApi -import akka.javasdk.eventsourcedentity.EventSourcedEntity -import akka.javasdk.impl.Service -import akka.javasdk.impl.serialization.JsonSerializer -import kalix.protocol.event_sourced_entity._ - -// FIXME remove - -/** - * INTERNAL API - */ -@InternalApi -private[impl] final case class EventSourcedEntityService[S, E, ES <: EventSourcedEntity[S, E]]( - eventSourcedEntityClass: Class[_], - _serializer: JsonSerializer) - extends Service(eventSourcedEntityClass, EventSourcedEntities.name, _serializer) {} diff --git a/akka-javasdk/src/main/scala/akka/javasdk/impl/keyvalueentity/KeyValueEntityService.scala b/akka-javasdk/src/main/scala/akka/javasdk/impl/keyvalueentity/KeyValueEntityService.scala deleted file mode 100644 index 4e781b31c..000000000 --- a/akka-javasdk/src/main/scala/akka/javasdk/impl/keyvalueentity/KeyValueEntityService.scala +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2021-2024 Lightbend Inc. - */ - -package akka.javasdk.impl.keyvalueentity - -import akka.annotation.InternalApi -import akka.javasdk.impl.Service -import akka.javasdk.impl.serialization.JsonSerializer -import akka.javasdk.keyvalueentity.KeyValueEntity -import kalix.protocol.value_entity._ - -// FIXME remove - -/** - * INTERNAL API - */ -@InternalApi -private[impl] final class KeyValueEntityService[S, E <: KeyValueEntity[S]]( - entityClass: Class[E], - serializer: JsonSerializer) - extends Service(entityClass, ValueEntities.name, serializer) diff --git a/akka-javasdk/src/main/scala/akka/javasdk/impl/workflow/WorkflowImpl.scala b/akka-javasdk/src/main/scala/akka/javasdk/impl/workflow/WorkflowImpl.scala index 92dfaf06b..64cc92e25 100644 --- a/akka-javasdk/src/main/scala/akka/javasdk/impl/workflow/WorkflowImpl.scala +++ b/akka-javasdk/src/main/scala/akka/javasdk/impl/workflow/WorkflowImpl.scala @@ -19,7 +19,6 @@ import akka.javasdk.impl.ActivatableContext import akka.javasdk.impl.ComponentDescriptor import akka.javasdk.impl.ErrorHandling.BadRequestException import akka.javasdk.impl.MetadataImpl -import akka.javasdk.impl.Service import akka.javasdk.impl.WorkflowExceptions.WorkflowException import akka.javasdk.impl.serialization.JsonSerializer import akka.javasdk.impl.telemetry.SpanTracingImpl @@ -49,7 +48,6 @@ import akka.runtime.sdk.spi.SpiWorkflow import akka.runtime.sdk.spi.TimerClient import io.opentelemetry.api.trace.Span import io.opentelemetry.api.trace.Tracer -import kalix.protocol.workflow_entity.WorkflowEntities /** * INTERNAL API @@ -245,21 +243,6 @@ class WorkflowImpl[S, W <: Workflow[S]]( } -/** - * INTERNAL API - */ -@InternalApi -final class WorkflowService[S, W <: Workflow[S]]( - workflowClass: Class[_], - serializer: JsonSerializer, - instanceFactory: Function[WorkflowContext, W]) - extends Service(workflowClass, WorkflowEntities.name, serializer) { - - def createRouter(context: WorkflowContext) = - new ReflectiveWorkflowRouter[S, W](instanceFactory(context), componentDescriptor.commandHandlers, serializer) - -} - /** * INTERNAL API */ diff --git a/docs/src/modules/java/pages/event-sourced-entities.adoc b/docs/src/modules/java/pages/event-sourced-entities.adoc index 4b6cfac38..bb68aea4f 100644 --- a/docs/src/modules/java/pages/event-sourced-entities.adoc +++ b/docs/src/modules/java/pages/event-sourced-entities.adoc @@ -241,33 +241,3 @@ include::example$shopping-cart-quickstart/src/it/java/shoppingcart/IntegrationTe <6> Assert there should only be one item. NOTE: The integration tests in samples are under a specific project profile `it` and can be run using `mvn verify -Pit`. - -== Exposing entities directly - -include::partial$component-endpoint.adoc[] - -=== API - -The entity is exposed at a fixed path: - -[source] ----- -/akka/v1.0/entity/// ----- - -In our shopping cart example that is: - -[source,shell] ----- -curl localhost:9000/akka/v1.0/entity/carts/12345/getCart ----- - -or, to add an item: - -[source,shell] ----- -curl localhost:9000/akka/v1.0/entity/carts/12345/addItem \ - --header "Content-Type: application/json" \ - -XPOST \ - --data '{"productId":"akka-tshirt","name":"Akka Tshirt","quantity":10}' ----- diff --git a/docs/src/modules/java/pages/key-value-entities.adoc b/docs/src/modules/java/pages/key-value-entities.adoc index 42ce4a0b7..aedf7a650 100644 --- a/docs/src/modules/java/pages/key-value-entities.adoc +++ b/docs/src/modules/java/pages/key-value-entities.adoc @@ -160,24 +160,4 @@ include::example$key-value-counter/src/it/java/com/example/CounterIntegrationTes <4> Request to increase the value of counter `bar`. Response should have value `1`. <5> Explicitly request current value of `bar`. It should be `1`. -NOTE: The integration tests in samples are under a specific project profile `it` and can be run using `mvn verify -Pit`. - -== Exposing entities directly - -include::partial$component-endpoint.adoc[] - -=== API - -The entity is exposed at a fixed path: - -[source] ----- -/akka/v1.0/entity/// ----- - -In our counter example that is: - -[source,shell] ----- -curl localhost:9000/akka/v1.0/entity/counter/foo/get ----- +NOTE: The integration tests in samples are under a specific project profile `it` and can be run using `mvn verify -Pit`. \ No newline at end of file diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 700119281..694e7fc4d 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -8,7 +8,7 @@ object Dependencies { val ProtocolVersionMinor = 1 val RuntimeImage = "gcr.io/kalix-public/kalix-runtime" // Remember to bump kalix-runtime.version in akka-javasdk-maven/akka-javasdk-parent if bumping this - val RuntimeVersion = sys.props.getOrElse("kalix-runtime.version", "1.3.0-f5764fe") + val RuntimeVersion = sys.props.getOrElse("kalix-runtime.version", "1.3.0-03a3a40") } // NOTE: embedded SDK should have the AkkaVersion aligned, when updating RuntimeVersion, make sure to check // if AkkaVersion and AkkaHttpVersion are aligned diff --git a/samples/choreography-saga-quickstart/controller-requests.http b/samples/choreography-saga-quickstart/controller-requests.http index 36a5194d6..45388b8bd 100644 --- a/samples/choreography-saga-quickstart/controller-requests.http +++ b/samples/choreography-saga-quickstart/controller-requests.http @@ -63,7 +63,4 @@ GET localhost:9000/api/users/002 ### get by country -GET localhost:9000/api/users/by-country/Belgium - -### doe@acme info - forbiden call (ACL blocks it) -GET localhost:9000/akka/v1.0/entity/unique-address/doe@acme.com/getState \ No newline at end of file +GET localhost:9000/api/users/by-country/Belgium \ No newline at end of file diff --git a/samples/key-value-customer-registry/README.md b/samples/key-value-customer-registry/README.md index 8c942891e..642a9d9f2 100644 --- a/samples/key-value-customer-registry/README.md +++ b/samples/key-value-customer-registry/README.md @@ -153,40 +153,6 @@ Start this query in one terminal window while triggering updates in another term changing the name to and from "Jan Janssen" or adding more customers with different ids and the same name, to see the updates appear. -## Pre-defined paths - -Akka runtime provides pre-defined paths based on the component id, entity id and the method name to interact directly -with the entities, those are however locked down from access through default deny-all ACLs. It is possible to explicitly -allow access on an entity using the `akka.javasdk.annotations.Acl` annotation, or by completely disabling the local -"dev mode" ACL checking by running the service with `mvn -Dakka.javasdk.dev-mode.acl.enabled=false compile exec:java` -or changing the default in your `src/main/resources/application.conf`. - -For deployed services the ACLs are always enabled. - -Zero parameter methods are exposed as HTTP GET: - -```shell -curl localhost:9000/akka/v1.0/entity/customer/002/getCustomer -``` - -Methods with a parameter are instead exposed as HTTP POST: - -```shell -curl -i localhost:9000/akka/v1.0/entity/customer/004/create \ - --header "Content-Type: application/json" \ - -XPOST \ - --data '{"email":"test4@example.com","name":"Test 4 Testsson","address":{"street":"Teststreet 27","city":"Testcity"}}' -``` - -The views: - -```shell -curl localhost:9000/akka/v1.0/view/customers_by_email/getCustomer \ - --header "Content-Type: application/json" \ - -XPOST \ - --data '{"email":"test4@example.com"}' -``` - ## Deploying You can use the [Akka Console](https://console.akka.io) to create a project and see the status of your service.