trait Entity[F[_], S, E] extends StateReader[F, S] with StateReaderHelpers[F, S] with 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.
- F
context
- S
state
- E
event
- See also
DurableEntity
for the equivalent without event-sourcing
- Alphabetic
- By Inheritance
- Entity
- EventWriter
- StateReaderHelpers
- StateReader
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- implicit abstract def monad: Monad[F]
- Definition Classes
- StateReaderHelpers
- abstract 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
- returns
optional state in
F
context
- Definition Classes
- StateReader
- abstract 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
- event
event
- other
more events
- Definition Classes
- EventWriter
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def ifKnown[Error, A](fa: (S) => A)(ifUnknown: => Error): F[\/[Error, A]]
Convenience function which applies
fa
on the state if entity exists and wraps this in aRight
, otherwise returns aLeft
with the provided error value.Convenience function which applies
fa
on the state if entity exists and wraps this in aRight
, otherwise returns aLeft
with the provided error value.- fa
function to apply on state
- ifUnknown
left value in case of missing entity
- Definition Classes
- 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 valueConvenience function which applies
fa
on the state if entity exists, otherwise returns a default value- fa
function to apply on state
- ifUnknownF
value in case of missing entity in
F
context
- Definition Classes
- StateReaderHelpers
- def ifKnownF[Error, A](fa: (S) => F[A])(ifUnknown: => Error): F[\/[Error, A]]
Convenience function which applies
fa
on the state if entity exists and wraps this in aRight
, otherwise returns aLeft
with the provided error value.Convenience function which applies
fa
on the state if entity exists and wraps this in aRight
, otherwise returns aLeft
with the provided error value.- fa
function to apply on state
- ifUnknown
left value in case of missing entity
- Definition Classes
- StateReaderHelpers
- def ifKnownFE[Error, A](fa: (S) => F[\/[Error, A]])(ifUnknown: => Error): F[\/[Error, A]]
Convenience function which applies
fa
on the state if entity exists, otherwise returns aLeft
with the provided error value.Convenience function which applies
fa
on the state if entity exists, otherwise returns aLeft
with the provided error value.- fa
function to apply on state
- ifUnknown
left value in case of missing entity
- Definition Classes
- StateReaderHelpers
- def ifKnownT[Error, A](fa: (S) => EitherT[F, Error, A])(ifUnknown: => Error): F[\/[Error, A]]
Convenience function which applies
fa
on the state if entity exists and unwraps EitherT value, otherwise returns aLeft
with the provided error value.Convenience function which applies
fa
on the state if entity exists and unwraps EitherT value, otherwise returns aLeft
with the provided error value.- fa
function to apply on state
- ifUnknown
left value in case of missing entity
- Definition Classes
- StateReaderHelpers
- def ifUnknown[Error, A](a: => A)(ifKnown: (S) => Error): F[\/[Error, A]]
Convenience function which returns a in a
Right
if entity doesn't yet exist, otherwise callsifKnown
with the state and wraps this in aLeft
.Convenience function which returns a in a
Right
if entity doesn't yet exist, otherwise callsifKnown
with the state and wraps this in aLeft
.- ifKnown
function to compute left value in case of existing entity
- Definition Classes
- StateReaderHelpers
- def ifUnknownElse[A](fa: => F[A])(ifKnown: (S) => F[A]): F[A]
Convenience function which returns a value
fa
inF
context, otherwise callsifKnown
with the stateConvenience function which returns a value
fa
inF
context, otherwise callsifKnown
with the state- fa
value in case of missing entity in
F
context- ifKnown
function to apply on state
- Definition Classes
- StateReaderHelpers
- def ifUnknownF[Error, A](fa: => F[A])(ifKnown: (S) => Error): F[\/[Error, A]]
Convenience function which invokes
fa
if entity doesn't yet exist and wraps this in aRight
, otherwise callsifKnown
with the state and wraps this in aLeft
.Convenience function which invokes
fa
if entity doesn't yet exist and wraps this in aRight
, otherwise callsifKnown
with the state and wraps this in aLeft
.- fa
success value when entity doesn't exist yet
- ifKnown
function to compute left value in case of existing entity
- Definition Classes
- StateReaderHelpers
- def ifUnknownFE[Error, A](fa: => F[\/[Error, A]])(ifKnown: (S) => Error): F[\/[Error, A]]
Convenience function which invokes
fa
if entity doesn't yet exist and wraps this in aRight
, otherwise callsifKnown
with the state and wraps this in aLeft
.Convenience function which invokes
fa
if entity doesn't yet exist and wraps this in aRight
, otherwise callsifKnown
with the state and wraps this in aLeft
.- fa
success value when entity doesn't exist yet
- ifKnown
function to compute left value in case of existing entity
- Definition Classes
- StateReaderHelpers
- def ifUnknownT[Error, A](fa: => EitherT[F, Error, A])(ifKnown: (S) => Error): F[\/[Error, A]]
Convenience function which invokes
fa
if entity doesn't yet exist, otherwise calls ,ifKnown
with the the state and wraps this in aLeft
.Convenience function which invokes
fa
if entity doesn't yet exist, otherwise calls ,ifKnown
with the the state and wraps this in aLeft
.- fa
value wrapped in
EitherT
when entity doesn't exist yet- ifKnown
function to compute left value in case of existing entity
- Definition Classes
- StateReaderHelpers
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)