Entity

endless.core.entity.Entity
trait Entity[F[_], S, E] extends StateReader[F, S], StateReaderHelpers[F, S], EventWriter[F, E]

Entity[F, S, E] is the ability to read an event-sourced entity state of type S and append events of type E affecting this state.

These dual reader/writer abilities are what is needed to describe command handler behavior. When interpreting code involving Entity, the final resulting value in the monadic chain is typically understood as the reply, and all appended events are persisted to the journal atomically by the runtime. Read always provides the up-to-date state however, thanks to event folding happening within the interpreter, ensuring consistency throughout the chain.

Type parameters

E

event

F

context

S

state

Attributes

See also

DurableEntity for the equivalent without event-sourcing

Graph
Supertypes
trait EventWriter[F, E]
trait StateReaderHelpers[F, S]
trait StateReader[F, S]
class Object
trait Matchable
class Any
Show all
Known subtypes
class EntityTLiftInstance[F, S, E]

Members list

Value members

Inherited methods

def ifKnown[Error, A](fa: S => A)(ifUnknown: => Error): F[Either[Error, A]]

Convenience function which applies fa on the state if entity exists and wraps this in a Right, otherwise returns a Left with the provided error value.

Convenience function which applies fa on the state if entity exists and wraps this in a Right, otherwise returns a Left with the provided error value.

Value parameters

fa

function to apply on state

ifUnknown

left value in case of missing entity

Attributes

Inherited from:
StateReaderHelpers
def ifKnownElse[A](fa: S => F[A])(ifUnknownF: => F[A]): F[A]

Convenience function which applies fa on the state if entity exists, otherwise returns a default value

Convenience function which applies fa on the state if entity exists, otherwise returns a default value

Value parameters

fa

function to apply on state

ifUnknownF

value in case of missing entity in F context

Attributes

Inherited from:
StateReaderHelpers
def ifKnownF[Error, A](fa: S => F[A])(ifUnknown: => Error): F[Either[Error, A]]

Convenience function which applies fa on the state if entity exists and wraps this in a Right, otherwise returns a Left with the provided error value.

Convenience function which applies fa on the state if entity exists and wraps this in a Right, otherwise returns a Left with the provided error value.

Value parameters

fa

function to apply on state

ifUnknown

left value in case of missing entity

Attributes

Inherited from:
StateReaderHelpers
def ifKnownFE[Error, A](fa: S => F[Either[Error, A]])(ifUnknown: => Error): F[Either[Error, A]]

Convenience function which applies fa on the state if entity exists, otherwise returns a Left with the provided error value.

Convenience function which applies fa on the state if entity exists, otherwise returns a Left with the provided error value.

Value parameters

fa

function to apply on state

ifUnknown

left value in case of missing entity

Attributes

Inherited from:
StateReaderHelpers
def ifKnownT[Error, A](fa: S => EitherT[F, Error, A])(ifUnknown: => Error): F[Either[Error, A]]

Convenience function which applies fa on the state if entity exists and unwraps EitherT value, otherwise returns a Left with the provided error value.

Convenience function which applies fa on the state if entity exists and unwraps EitherT value, otherwise returns a Left with the provided error value.

Value parameters

fa

function to apply on state

ifUnknown

left value in case of missing entity

Attributes

Inherited from:
StateReaderHelpers
def ifUnknown[Error, A](a: => A)(ifKnown: S => Error): F[Either[Error, A]]

Convenience function which returns a in a Right if entity doesn't yet exist, otherwise calls ifKnown with the state and wraps this in a Left.

Convenience function which returns a in a Right if entity doesn't yet exist, otherwise calls ifKnown with the state and wraps this in a Left.

Value parameters

fa

success value when entity doesn't exist yet

ifKnown

function to compute left value in case of existing entity

Attributes

Inherited from:
StateReaderHelpers
def ifUnknownElse[A](fa: => F[A])(ifKnown: S => F[A]): F[A]

Convenience function which returns a value fa in F context, otherwise calls ifKnown with the state

Convenience function which returns a value fa in F context, otherwise calls ifKnown with the state

Value parameters

fa

value in case of missing entity in F context

ifKnown

function to apply on state

Attributes

Inherited from:
StateReaderHelpers
def ifUnknownF[Error, A](fa: => F[A])(ifKnown: S => Error): F[Either[Error, A]]

Convenience function which invokes fa if entity doesn't yet exist and wraps this in a Right, otherwise calls ifKnown with the state and wraps this in a Left.

Convenience function which invokes fa if entity doesn't yet exist and wraps this in a Right, otherwise calls ifKnown with the state and wraps this in a Left.

Value parameters

fa

success value when entity doesn't exist yet

ifKnown

function to compute left value in case of existing entity

Attributes

Inherited from:
StateReaderHelpers
def ifUnknownFE[Error, A](fa: => F[Either[Error, A]])(ifKnown: S => Error): F[Either[Error, A]]

Convenience function which invokes fa if entity doesn't yet exist and wraps this in a Right, otherwise calls ifKnown with the state and wraps this in a Left.

Convenience function which invokes fa if entity doesn't yet exist and wraps this in a Right, otherwise calls ifKnown with the state and wraps this in a Left.

Value parameters

fa

success value when entity doesn't exist yet

ifKnown

function to compute left value in case of existing entity

Attributes

Inherited from:
StateReaderHelpers
def ifUnknownT[Error, A](fa: => EitherT[F, Error, A])(ifKnown: S => Error): F[Either[Error, A]]

Convenience function which invokes fa if entity doesn't yet exist, otherwise calls , ifKnown with the the state and wraps this in a Left.

Convenience function which invokes fa if entity doesn't yet exist, otherwise calls , ifKnown with the the state and wraps this in a Left.

Value parameters

fa

value wrapped in EitherT when entity doesn't exist yet

ifKnown

function to compute left value in case of existing entity

Attributes

Inherited from:
StateReaderHelpers
def read: F[Option[S]]

Read the entity state, returns None if the entity doesn't yet exist

Read the entity state, returns None if the entity doesn't yet exist

Attributes

Returns

optional state in F context

Inherited from:
StateReader
def write(event: E, other: E*): F[Unit]

Append events to the event log in context F

Append events to the event log in context F

Value parameters

event

event

other

more events

Attributes

Inherited from:
EventWriter

Implicits

Inherited implicits

implicit def monad: Monad[F]

Attributes

Inherited from:
StateReaderHelpers