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
  • abstract class ServiceFragment extends ActorService with ServiceEndpoints

    A service fragment is an object defining a logical service.

    A service fragment is an object defining a logical service. Service fragments must be instantiated under a group with a name to use. This scopes all endpoints, authorization, and entity data to that group and name.

    An object extending this class declares a new service fragment. A service has a protocol of commands, queries and events. Operators can use the protocol directly. Users can only use the protocol through the declared endpoints.

    The usability focus is on rapid development and data acquisition:

    • easy declaration of the commands, queries and events
    • automatic auditing
    • components for common business as a service activities

    A service is three declarations:

    • A protocol consisting of commands and queries
    • A mapping from protocol messages to implementations
    • an interface exported to users as endpoints

    This is implemented in this EDSL as:

    • Types in the Proto hierarchy. Commands extend Command and Queries extend Query.
    • Implementations defined by (partial) functions from messages in this protocol to a handler. Handlers can delegate to akka actors, event source entities, ZIO actions, or plain functions.
    • the exports of commands and queries are REST endpoints. These consist of explicit (verb, path components, data) and implicit (auth token, session token, csrf token, origin) data plus a mapping to the Proto.
    Definition Classes
    server
    Examples:
    1. Scopes If services.IntegerCounters was instantiated under a group doors with the service name entrances and exits then these would not share data. The entity /doors/entrances/front would have a different state than /doors/exits/front. Even though the object, IntegerCounters, is the same.

    2. ,
    3. Minimal service fragment definition

      import glngn.prelude._
      
      object MinimalServiceFragment extends ServiceFragment {
        sealed trait Proto extends Message
      }
    4. ,
    5. A hypothetical service fragment definition

      // a hypothetical service for account balances
      final object ClientBalanceFragment extends ServiceFragment {
        type AccountId = EntityId
        type CurrencyValue = Int // fractions of currency unit
      
        // messages in the protocol
        sealed trait Proto extends Message
        // a command to increase the balance of an account
        case class IncBalanceForAccount(account: AccountId, amount: CurrencyValue)
          extends Command[CurrencyValue] with Proto
        // a command to decrease the balance of an account
        case class DecBalanceForAccount(account: AccountId, amount: CurrencyValue)
          extends Command[CurrencyValue] with Proto
        // a query to retrieve the account balance
        case class GetBalanceForAccount(account: AccountId)
          extends Query[CurrencyValue] with Proto
        // an event outside of the command/query model.
        case class RequestAudit(account: AccountId) extends Proto
      
        override def instantiate(env: InstanceEnv) = new Instance(env) {
          import Bindings.{delegate, entity, async}
      
          // the service protocol is implemented using...
          val bindings = bindingsChain(
            // ... a akka typed Behavior[Envelope] delegate
            delegate {
              Behaviors.receiveMessagePartial
                case Event(RequestAudit) => ???
              }
              // Note the use of a partial function: unhandled messages will propagate to the
              // next binding. (Even if the delegate behavior above changes)
            },
            // ... operations on a named counter entity
            entity(NamedValue) {
              case IncBalanceForAccount(accountId, amount) => CounterEntity.Inc(amount) -> accountId
              case DecBalanceForAccount(accountId, amount) => CounterEntity.Dec(amount) -> accountId
              case GetBalanceForAccount(accountId)         => CounterEntity.Get         -> accountId
            },
            // ... a daemon sending Proto messages back to this service
            async(OrdersOverSMSBehavior) // where OrdersOverSMSBehavior being a [[ServiceActorDaemon]]
          )
      
          import Endpoints.{query, command}
      
          // The protocol is exported to users with the endpoints
          def endpoints: Endpoints[_] = endpointsChain(
            // results in the REST interface:
            //
            // GET $accountName
            // POST $accountName/inc
            // POST $accountName/dec
            //
            // once instantiated this is schema can be viewed under /openapi.json
            query.entityId { accountName =>
              GetBalanceForAccount(accountName)
            },
            command.entityId.slug("inc").value[CurrencyValue] { (accountId, amount) =>
              IncBalanceForAccount(accountId, amount)
            },
            command.entityId.slug("dec").value[CurrencyValue] { (accountId, amount) =>
              DecBalanceForAccount(accountId, amount)
            }
          )
        }
      }
  • Bindings
  • BindingsInstance
  • Command
  • DelegateOps
  • Endpoints
  • EndpointsInstance
  • EndpointsOp
  • Envelope
  • Event
  • Instance
  • InstanceEnv
  • Proto
  • Query
  • Request
  • ServiceInstance
  • StopEnvelope

abstract class Instance extends EndpointsInstance with ServiceInstance

Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. Instance
  2. ServiceInstance
  3. EndpointsInstance
  4. BindingsInstance
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Instance(env: InstanceEnv)(implicit opsSchema: OpsSchema[ServiceFragment.Proto])

Abstract Value Members

  1. abstract val bindings: ServiceFragment.Bindings[_]

    All events in this service are bound to an implementation.

    All events in this service are bound to an implementation. A ServiceFragment has a default implementation of delegating to the _ops service for all events.

    The bindings are attempted in the order the declarations encountered in evaluation.

    val bindings = {
      import Bindings._
      empty
    }
    Definition Classes
    BindingsInstance
  2. abstract def endpoints: ServiceFragment.Endpoints[_]

    Published endpoints for operations.

    Published endpoints for operations. Each endpoint is a function from input to operation. The type of the operation implies the output type.

    One explicit non-goal is: Requiring both GET and POST for all resources. Query (pure) and update (effects) are independent. This is reflected by independent command and query statements within this DSL.

    TODO: The properties of a request, including authorization and authentication claims, are available in the, optional, Properties argument to handlers.

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. final def bindingsChain(ops: ServiceFragment.Bindings[_]*): ServiceFragment.Bindings[_]

    Create a Bindings from a chain of Bindings$ operations.

    Create a Bindings from a chain of Bindings$ operations.

    This is equivalent to a sequence fold on the List of the arguments. Examples prefer chain over .sequence_ for clarity.

    Definition Classes
    BindingsInstance
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  7. final def config: Config

    Service configuration.

    Service configuration.

    TODO: currently full deployment configuration.

    Definition Classes
    BindingsInstance
  8. def endpointsChain(es: ServiceFragment.Endpoints[_]*): ServiceFragment.Endpoints[_]

    Sequence of Endpoints.

    Sequence of Endpoints.

    Exactly the sequence_ in Foldable.

    Definition Classes
    EndpointsInstance
  9. val env: InstanceEnv

    The service actor instance environment.

    The service actor instance environment.

    Definition Classes
    InstanceBindingsInstance
  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  15. final def instance[T](implicit arg0: Manifest[T]): T

    Summon of an instance given type from the impure bindings.

    Summon of an instance given type from the impure bindings.

    Definition Classes
    BindingsInstance
  16. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  17. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  20. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  21. def toString(): String
    Definition Classes
    AnyRef → Any
  22. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from AnyRef

Inherited from Any

Domain

Service Logic

Implementation Detail

Ungrouped