trait DurableEntity[F[_], S] extends StateReader[F, S] with StateReaderHelpers[F, S] with StateWriter[F, S]
DurableEntity[F, S]
is the ability to read and write an entity state of type S
together with
the ability to compose such dependent effectful functions.
These dual reader/writer abilities are what is needed to describe command handler behavior. This
model enables a stateful entity to store the full state after processing each command instead of
using event sourcing. When interpreting code involving DurableEntity
, the final resulting
value in the monadic chain is typically understood as the reply, and any written state is
persisted behind the scenes by the runtime. Read always provides the state as it was last
written.
- F
context
- S
state
- See also
Entity
for the event-sourcing equivalent
- Alphabetic
- By Inheritance
- DurableEntity
- StateWriter
- StateReaderHelpers
- StateReader
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def modify(f: (S) => S): F[Unit]
Modify the entity state with the given function
Modify the entity state with the given function
- f
state modifier
- returns
unit in
F
context
- Definition Classes
- StateWriter
- abstract def modifyF(f: (S) => F[S]): F[Unit]
Modify the entity state with the given function expressed in
F
contextModify the entity state with the given function expressed in
F
context- f
state modifier in
F
context- returns
unit in
F
context
- Definition Classes
- StateWriter
- 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(s: S): F[Unit]
Write the entity state
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)