Entity
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
-
class Objecttrait Matchableclass AnyShow all
- Known subtypes
-
Members list
Value members
Inherited methods
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
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
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
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
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
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
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
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
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
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
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
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
Attributes
- Inherited from:
- StateReaderHelpers