Packages

  • package root

    glngn server is a low-code business process as a service rapid development system.

    glngn server is a low-code business process as a service rapid development system. Conceptually similar to a programmable Microsoft Access or Apple FileMaker for scalable event sourced business services. In addition to a library, a standalone application is provided that is useful with minimal ceremony. This can be customized with a simple API. As well as deployed to a kubernetes cluster should those advantages be required.

    A deployment is cluster of glngn.server.node.AppNodes serving a dynamic composition of glngn.server.ServiceFragments. Deployments are designed to be fully usable as a standalone local application or a kubernetes service.

    Contact support@dogheadbone.com for support and licensing.

    Definition Classes
    root
  • package glngn
    Definition Classes
    root
  • package server

    Definition Classes
    glngn
  • package core
    Definition Classes
    server
  • package entities
    Definition Classes
    server
  • package host
    Definition Classes
    server
  • package model
    Definition Classes
    server
  • package prelude

    Provides a custom prelude that re-exports common dependencies.

    Provides a custom prelude that re-exports common dependencies. This will re-export

    Useful for initial developments. If the external prelude conflicts with additional imports there will be odd "no implicit found" errors. In which case this prelude is not appropriate to use.

    import glngn.prelude._

    Use of this prelude is not required. Each aspect is provided as a mix-in and separate object.

    For example, to import only the types and values defined in glngn.server that are generally useful for development:

    import glngn.server.prelude.GlngnServerPrelude._
    Definition Classes
    server
  • package services
    Definition Classes
    server
  • AppEnvironment
  • AppIO
  • Config
  • ServiceEntity
  • ServiceFragment
t

glngn.server

ServiceEntity

trait ServiceEntity extends ServiceActor

An event sourced persistent entity definition. The entity refers to all actors defined by the the Id.

This is implemented using typed akka persistent actors and cluster sharding. Additional functionality:

- always replies when handing a request - will automatically derive a JSON codec for Storage events - StopEnvelope will always stop the entity - entity will automatically passivate after no events

import glngn.server.prelude._

final object MyServiceEntity extends ServiceEntity {
  val name = "my-service-entity"

  // example declaration of state as case class
  final case class State(state: String) extends Message

  // standard Proto and Storage declarations as sealed traits
  sealed trait Proto extends Message
  sealed trait Storage extends Proto

  // a request event that's recorded to storage
  final case class Add(value: String) extends Command[State] with Storage with Proto

  def activity(injector: ImpureInjector, id: Id) = new Activity(injector) {
    val init = State(Map.empty)

    def protoHandler(ctx: ActorContext[Envelope], state: State) = {
      case persistedEvent: Storage => Handler.persist(persistedEvent)
      case _: Proto                => Handler.none
    }

    def storageHandler(state: State) = {
      case add: Add => state.copy(state = state.state + add.value)
    }
  }
}
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. ServiceEntity
  2. ServiceActor
  3. DirectLogging
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. abstract class Activity extends AnyRef

    The entity defines the activity of an instance.

    The entity defines the activity of an instance. This activity defines the

    • the initial state
    • effects of protocol messages
    • change of state on storage events
    def activity(injector: ImpureInjector, id: Id) = new Activity(injector) {
      val init = State(0)
    
      def protoHandler(ctx: ActorContext[Envelope], state: State) = {
        case storage: Storage => Handler.persist(storage)
        case _                => Handler.none
      }
    
      def storageHandler(state: State) = {
        case Inc(amount) => {
          State(state.value + amount)
        }
        case Dec(amount) => {
          State(state.value - amount)
        }
        case Set(value) => {
          State(value)
        }
      }
    }
    Attributes
    protected
  2. final type AnyRequest = Proto with Request[_]

    AnyRequest is a Command or Query with no particular response type.

    AnyRequest is a Command or Query with no particular response type.

    Definition Classes
    ServiceActor
  3. sealed trait Handler extends AnyRef

    Defines how protocol messages will be handled, see Handler$.

    Defines how protocol messages will be handled, see Handler$.

    Similar API to akka's Effect:

    • what events should be persisted?
    • what IO should occur after any events are persisted and integrated into State?
    • should the current protocol message be stashed? Or should messages be unstashed?
  4. type Id = String

  5. case class OpenHandler extends Handler with Product with Serializable

    A Handler that can be extend with IO actions.

  6. abstract type Proto <: Message

    Type of protocol messages this service entity supports.

    Type of protocol messages this service entity supports.

    sealed trait Proto extends Message
    Definition Classes
    ServiceEntityServiceActor
  7. final type RequestWithId = (Request[State] with Proto, Id)

  8. sealed trait SealedHandler extends Handler

    A Handler that cannot be extended with IO actions.

  9. abstract type State

    Entity state type.

  10. abstract type Storage <: Message

    Type of persisted events.

    Type of persisted events.

    sealed trait Storage extends Message
    sealed trait Storage extends Proto
  11. abstract class Command[Response] extends Request[Response] with proto.ProtoDecl.Command with proto.ProtoDecl.Request

    All commands are Requests with Proto: extends Command[R] with Proto.

    All commands are Requests with Proto: extends Command[R] with Proto.

    sealed trait Proto extends Message
    case class ExampleCommand(msg: String) extends Command[ExampleResponse] with Proto
    Definition Classes
    ServiceActor
  12. sealed trait Envelope extends Product with Message with Serializable

    A Proto event with additional attributes and claims.

    A Proto event with additional attributes and claims. To pattern match on an Envelope use the Event.unapply or Request.unapply extractors.

    val behavior: Behavior[Envelope] = Behaviors.receiveMessagePartial {
      case Event(SomeEvent(eventData)) => ???
      case Request(scope, SomeCommand(eventData)) => ???
    }

    An Envelope can be implicitly constructed from any Proto.

    val delegate: ActorRef[Envelope] = ???
    val anEvent: Proto = SomeEvent(eventData)
    delegate ! anEvent
    Definition Classes
    ServiceActor
  13. abstract class Query[Response] extends Request[Response] with proto.ProtoDecl.Query with proto.ProtoDecl.Request

    All queries are Requests with Proto: extends Query[R] with Proto.

    All queries are Requests with Proto: extends Query[R] with Proto.

    sealed trait Proto extends Message
    case class ExampleQuery(msg: String) extends Query[ExampleResponse] with Proto
    Definition Classes
    ServiceActor
  14. sealed abstract class Request[R] extends AnyRef

    A protocol event can be declared as a Request using Command or Query.

    A protocol event can be declared as a Request using Command or Query. The type parameter is the response that resolves the request.

    sealed trait Proto extends Message
    case class ExampleCommand(msg: String) extends Command[ExampleResponse] with Proto
    case class ExampleQuery(msg: String) extends Query[ExampleResponse] with Proto
    Definition Classes
    ServiceActor

Abstract Value Members

  1. abstract def activity(injector: ImpureInjector, id: Id): Activity

    An instance of Activity that defines the entity's behavior:

    An instance of Activity that defines the entity's behavior:

    • the initial state
    • effects of protocol messages
    • change of state on storage events
    def activity(injector: ImpureInjector, id: Id) = new Activity(injector) {
      val init = State(0)
    
      def protoHandler(ctx: ActorContext[Envelope], state: State) = {
        case storage: Storage => Handler.persist(storage)
        case _                => Handler.none
      }
    
      def storageHandler(state: State) = {
        case Inc(amount) => {
          State(state.value + amount)
        }
        case Dec(amount) => {
          State(state.value - amount)
        }
        case Set(value) => {
          State(value)
        }
      }
    }
  2. abstract val name: EntityName

    Logical name of the entity.

    Logical name of the entity.

    final object AnEntity extends ServiceEntity {
      val name = "an-entity"
      ???
    }

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def behavior(entityDomain: EntityDomain, injector: ImpureInjector): (prelude.external.EntityContext) ⇒ prelude.external.Behavior[Envelope]

    Instantiates the activity as a persistent behavior.

    Instantiates the activity as a persistent behavior. Requests requiring replies will receive the result state in reply.

    Attributes
    protected[glngn]
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. lazy val logger: prelude.external.Logger

    Attributes
    protected
    Definition Classes
    DirectLogging
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  18. def toString(): String
    Definition Classes
    AnyRef → Any
  19. def typeKey(entityDomain: EntityDomain): prelude.external.EntityTypeKey[Envelope]

  20. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  23. object AutoPassivateTimerId

  24. object Handler

    Constructors for Handlers used in Activity.protoHandler.

  25. object OpenHandler extends Serializable

    See Handler$.

  26. object SealedHandler

  27. object Envelope extends Serializable

    Definition Classes
    ServiceActor
  28. object Event

    Any statement in the protocol can be considered an Event not associated with any additional scope.

    Any statement in the protocol can be considered an Event not associated with any additional scope.

    - see also ServiceActor.RequestScope and Request.unapply

    Definition Classes
    ServiceActor
  29. object Request

    Definition Classes
    ServiceActor
  30. object StopEnvelope extends Envelope with Product with Serializable

    Definition Classes
    ServiceActor

Inherited from ServiceActor

Inherited from AnyRef

Inherited from Any

Domain

Service Logic

Implementation Detail

Ungrouped