Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.akkaserverless.javasdk.impl.eventsourcedentity.ResolvedEventSourcedEntityFactory;
import com.akkaserverless.javasdk.impl.replicatedentity.ReplicatedEntityService;
import com.akkaserverless.javasdk.impl.replicatedentity.ResolvedReplicatedEntityFactory;
import com.akkaserverless.javasdk.impl.Service;
import com.akkaserverless.javasdk.impl.valueentity.ResolvedValueEntityFactory;
import com.akkaserverless.javasdk.impl.valueentity.ValueEntityService;
import com.akkaserverless.javasdk.impl.view.ViewService;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.akkaserverless.javasdk;

import com.akkaserverless.javasdk.impl.ComponentOptions;
/** Options used for configuring an entity. */
public interface EntityOptions extends ComponentOptions {

Expand All @@ -29,4 +30,16 @@ public interface EntityOptions extends ComponentOptions {
* @return the entity option
*/
EntityOptions withPassivationStrategy(PassivationStrategy strategy);

/**
* @return the headers requested to be forwarded as metadata (cannot be mutated, use
* withForwardHeaders)
*/
java.util.Set<String> forwardHeaders();

/**
* Ask Akka Serverless to forward these headers from the incoming request as metadata headers for
* the incoming commands. By default no headers except "X-Server-Timing" are forwarded.
*/
ComponentOptions withForwardHeaders(java.util.Set<String> headers);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.akkaserverless.javasdk.action;

import com.akkaserverless.javasdk.ComponentOptions;
import com.akkaserverless.javasdk.impl.ComponentOptions;
import com.akkaserverless.javasdk.PassivationStrategy;
import com.akkaserverless.javasdk.eventsourcedentity.EventSourcedEntityOptions;
import com.akkaserverless.javasdk.impl.action.ActionOptionsImpl;
Expand All @@ -31,4 +31,16 @@ public interface ActionOptions extends ComponentOptions {
static ActionOptions defaults() {
return new ActionOptionsImpl(Collections.emptySet());
}

/**
* @return the headers requested to be forwarded as metadata (cannot be mutated, use
* withForwardHeaders)
*/
java.util.Set<String> forwardHeaders();

/**
* Ask Akka Serverless to forward these headers from the incoming request as metadata headers for
* the incoming commands. By default no headers except "X-Server-Timing" are forwarded.
*/
ComponentOptions withForwardHeaders(java.util.Set<String> headers);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ import com.akkaserverless.javasdk.impl.action.{ ActionService, ActionsImpl }
import com.akkaserverless.javasdk.impl.replicatedentity.{ ReplicatedEntitiesImpl, ReplicatedEntityService }
import com.akkaserverless.javasdk.impl.valueentity.{ ValueEntitiesImpl, ValueEntityService }
import com.akkaserverless.javasdk.impl.eventsourcedentity.{ EventSourcedEntitiesImpl, EventSourcedEntityService }
import com.akkaserverless.javasdk.impl.{ DiscoveryImpl, ResolvedServiceCallFactory, ResolvedServiceMethod }
import com.akkaserverless.javasdk.impl.{
ComponentOptions,
DiscoveryImpl,
ResolvedServiceCallFactory,
ResolvedServiceMethod,
Service
}
import com.akkaserverless.protocol.action.ActionsHandler
import com.akkaserverless.protocol.discovery.DiscoveryHandler
import com.akkaserverless.protocol.event_sourced_entity.EventSourcedEntitiesHandler
Expand Down Expand Up @@ -213,41 +219,3 @@ final class AkkaServerlessRunner private[this] (
osMBean.getAvailableProcessors)
}
}

/**
* Service describes a component type in a way which makes it possible to deploy.
*/
trait Service {

/**
* @return
* a Protobuf ServiceDescriptor of its externally accessible gRPC API
*/
def descriptor: Descriptors.ServiceDescriptor

/**
* @return
* the type of component represented by this service
*/
def componentType: String

/**
* @return
* the entity type name used for the entities represented by this service
*/
def entityType: String = descriptor.getName

/**
* @return
* the options [[ComponentOptions]] or [[EntityOptions]] used by this service
*/
def componentOptions: Option[ComponentOptions] = None

/**
* @return
* a dictionary of service methods (Protobuf Descriptors.MethodDescriptor) classified by method name. The dictionary
* values represent a mapping of Protobuf Descriptors.MethodDescriptor with its input and output types (see
* [[com.akkaserverless.javasdk.impl.ResolvedServiceMethod]])
*/
def resolvedMethods: Option[Map[String, ResolvedServiceMethod[_, _]]]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@
* limitations under the License.
*/

package com.akkaserverless.scalasdk
package com.akkaserverless.javasdk.impl

//FIXME see if needed
trait ComponentOptions extends com.akkaserverless.javasdk.ComponentOptions
trait ComponentOptions {

/**
* @return
* the headers requested to be forwarded as metadata (cannot be mutated, use withForwardHeaders)
*/
def forwardHeaders(): java.util.Set[String]

/**
* Ask Akka Serverless to forward these headers from the incoming request as metadata headers for the incoming
* commands. By default no headers except "X-Server-Timing" are forwarded.
*/
def withForwardHeaders(headers: java.util.Set[String]): ComponentOptions
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package com.akkaserverless.javasdk.impl

import com.akkaserverless.javasdk.ComponentOptions

import java.util
import java.util.Collections

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.akkaserverless.javasdk.impl
import akka.Done
import akka.actor.{ ActorSystem, CoordinatedShutdown }
import com.akkaserverless.javasdk.replicatedentity.{ ReplicatedEntityOptions, WriteConsistency }
import com.akkaserverless.javasdk.{ BuildInfo, EntityOptions, Service }
import com.akkaserverless.javasdk.{ BuildInfo, EntityOptions }
import com.akkaserverless.protocol.action.Actions
import com.akkaserverless.protocol.discovery.PassivationStrategy.Strategy
import com.akkaserverless.protocol.discovery._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.akkaserverless.javasdk.impl

import com.akkaserverless.javasdk.{ Service, ServiceCallFactory, ServiceCallRef }
import com.akkaserverless.javasdk.{ ServiceCallFactory, ServiceCallRef }

class ResolvedServiceCallFactory(services: Map[String, Service]) extends ServiceCallFactory {
override def lookup[T](serviceName: String, methodName: String, methodType: Class[T]): ServiceCallRef[T] =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2021 Lightbend Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.akkaserverless.javasdk.impl
import com.google.protobuf.Descriptors

/**
* Service describes a component type in a way which makes it possible to deploy.
*/
trait Service {

/**
* @return
* a Protobuf ServiceDescriptor of its externally accessible gRPC API
*/
def descriptor: Descriptors.ServiceDescriptor

/**
* @return
* the type of component represented by this service
*/
def componentType: String

/**
* @return
* the entity type name used for the entities represented by this service
*/
def entityType: String = descriptor.getName

/**
* @return
* the options [[ComponentOptions]] or [[EntityOptions]] used by this service
*/
def componentOptions: Option[ComponentOptions] = None

/**
* @return
* a dictionary of service methods (Protobuf Descriptors.MethodDescriptor) classified by method name. The dictionary
* values represent a mapping of Protobuf Descriptors.MethodDescriptor with its input and output types (see
* [[com.akkaserverless.javasdk.impl.ResolvedServiceMethod]])
*/
def resolvedMethods: Option[Map[String, ResolvedServiceMethod[_, _]]]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.akkaserverless.javasdk.impl.action

import com.akkaserverless.javasdk.ComponentOptions
import com.akkaserverless.javasdk.impl.ComponentOptions
import com.akkaserverless.javasdk.action.ActionOptions

import java.util
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ import com.akkaserverless.javasdk.impl.effect.ErrorReplyImpl
import com.akkaserverless.javasdk.impl.effect.MessageReplyImpl
import com.akkaserverless.javasdk.impl.effect.SecondaryEffectImpl
import com.akkaserverless.javasdk.impl.eventsourcedentity.EventSourcedEntityHandler.CommandResult
import com.akkaserverless.javasdk.ComponentOptions
import com.akkaserverless.javasdk.Context
import com.akkaserverless.javasdk.Metadata
import com.akkaserverless.javasdk.Service
import com.akkaserverless.javasdk.ServiceCallFactory
import com.akkaserverless.protocol.event_sourced_entity.EventSourcedStreamIn.Message.{ Init => InInit }
import com.akkaserverless.protocol.event_sourced_entity.EventSourcedStreamIn.Message.{ Empty => InEmpty }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import com.akkaserverless.javasdk.impl.effect.{ EffectSupport, ErrorReplyImpl, M
import com.akkaserverless.javasdk.impl.replicatedentity.ReplicatedEntityEffectImpl.DeleteEntity
import com.akkaserverless.javasdk.impl.replicatedentity.ReplicatedEntityHandler.CommandResult
import com.akkaserverless.javasdk.replicatedentity._
import com.akkaserverless.javasdk.{ ComponentOptions, Context, Metadata, Service, ServiceCallFactory }
import com.akkaserverless.javasdk.{ Context, Metadata, ServiceCallFactory }
import com.akkaserverless.protocol.entity.Command
import com.akkaserverless.protocol.replicated_entity.ReplicatedEntityStreamIn.{ Message => In }
import com.akkaserverless.protocol.replicated_entity.ReplicatedEntityStreamOut.{ Message => Out }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ import akka.stream.scaladsl.Source
import com.akkaserverless.javasdk.AkkaServerlessRunner.Configuration

// FIXME these don't seem to be 'public API', more internals?
import com.akkaserverless.javasdk.ComponentOptions
import com.akkaserverless.javasdk.Context
import com.akkaserverless.javasdk.Metadata
import com.akkaserverless.javasdk.Service
import com.akkaserverless.javasdk.ServiceCallFactory
import com.akkaserverless.javasdk.valueentity._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import scala.util.control.NonFatal

import akka.actor.ActorSystem
import akka.stream.scaladsl.Source
import com.akkaserverless.javasdk.impl.ViewFactory
import com.akkaserverless.javasdk.{ Context, Metadata, Service, ServiceCallFactory }
import com.akkaserverless.javasdk.impl.{ Service, ViewFactory }
import com.akkaserverless.javasdk.{ Context, Metadata, ServiceCallFactory }
import com.akkaserverless.javasdk.impl._
import com.akkaserverless.javasdk.view.ViewCreationContext
import com.akkaserverless.javasdk.view.{ UpdateContext, View, ViewContext }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import scala.jdk.CollectionConverters._
import akka.Done
import akka.actor.ActorSystem
import com.typesafe.config.Config
import com.akkaserverless.javasdk.Service
import com.akkaserverless.javasdk.impl.Service
import com.akkaserverless.javasdk.{ AkkaServerlessRunner => Impl }

object AkkaServerlessRunner {
Expand Down