Trait/Object

com.rbmhtechnology.eventuate

EventsourcedWriter

Related Docs: object EventsourcedWriter | package eventuate

Permalink

trait EventsourcedWriter[R, W] extends EventsourcedView with EventsourcedWriterSuccessHandlers[R, W] with EventsourcedWriterFailureHandlers

An EventsourcedView designed to update external databases from events stored in its event log. It supports event processing patterns optimized for batch-updating external databases to create persistent views or read models:

An EventsourcedWriter may also implement an onCommand handler to process commands and save snapshots of internal state. Internal state is recovered by replaying events from the event log, optionally starting from a saved snapshot (see EventsourcedView for details). If a writer doesn't require full internal state recovery, it may define a custom starting position in the event log by returning a sequence number from readSuccess. If full internal state recovery is required instead, readSuccess should return None (which is the default).

Implementation notes:

R

Result type of the asynchronous read operation.

W

Result type of the asynchronous write operations.

See also

StatefulProcessor

EventsourcedProcessor

Linear Supertypes
EventsourcedWriterFailureHandlers, EventsourcedWriterSuccessHandlers[R, W], EventsourcedView, Stash, RequiresMessageQueue[DequeBasedMessageQueueSemantics], UnrestrictedStash, StashSupport, Actor, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. EventsourcedWriter
  2. EventsourcedWriterFailureHandlers
  3. EventsourcedWriterSuccessHandlers
  4. EventsourcedView
  5. Stash
  6. RequiresMessageQueue
  7. UnrestrictedStash
  8. StashSupport
  9. Actor
  10. AnyRef
  11. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type Handler[A] = (Try[A]) ⇒ Unit

    Permalink
    Definition Classes
    EventsourcedView
  2. type Receive = PartialFunction[Any, Unit]

    Permalink
    Definition Classes
    Actor

Abstract Value Members

  1. abstract def eventLog: ActorRef

    Permalink

    Event log actor.

    Event log actor.

    Definition Classes
    EventsourcedView
  2. abstract def id: String

    Permalink

    Global unique actor id.

    Global unique actor id.

    Definition Classes
    EventsourcedView
  3. abstract def onCommand: Receive

    Permalink

    Command handler.

    Command handler.

    Definition Classes
    EventsourcedView
  4. abstract def onEvent: Receive

    Permalink

    Event handler.

    Event handler.

    Definition Classes
    EventsourcedView
  5. abstract def read(): Future[R]

    Permalink

    Asynchronously reads an initial value from the target database, usually to obtain information about event processing progress.

    Asynchronously reads an initial value from the target database, usually to obtain information about event processing progress. This method is called during initialization.

  6. abstract def write(): Future[W]

    Permalink

    Asynchronously writes an incremental update to the target database.

    Asynchronously writes an incremental update to the target database. Incremental updates are prepared during event processing by a concrete onEvent handler.

    During event replay, this method is called latest after having replayed eventuate.log.replay-batch-size events and immediately after replay completes. During live processing, write is called immediately if no write operation is in progress and an event has been handled by onEvent. If a write operation is in progress, further event handling may run concurrently to that operation. If events are handled while a write operation is in progress, another write will follow immediately after the previous write operation completes.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def aggregateId: Option[String]

    Permalink

    Optional aggregate id.

    Optional aggregate id. It is used for routing DurableEvents to event-sourced destinations which can be EventsourcedViews or EventsourcedActors. By default, an event is routed to an event-sourced destination with an undefined aggregateId. If a destination's aggregateId is defined it will only receive events with a matching aggregate id in DurableEvent#destinationAggregateIds.

    Definition Classes
    EventsourcedView
  5. def aroundPostRestart(reason: Throwable): Unit

    Permalink
    Attributes
    protected[akka]
    Definition Classes
    Actor
    Annotations
    @InternalApi()
  6. def aroundPostStop(): Unit

    Permalink
    Attributes
    protected[akka]
    Definition Classes
    Actor
    Annotations
    @InternalApi()
  7. def aroundPreRestart(reason: Throwable, message: Option[Any]): Unit

    Permalink
    Attributes
    protected[akka]
    Definition Classes
    Actor
    Annotations
    @InternalApi()
  8. def aroundPreStart(): Unit

    Permalink
    Attributes
    protected[akka]
    Definition Classes
    Actor
    Annotations
    @InternalApi()
  9. def aroundReceive(receive: akka.actor.Actor.Receive, msg: Any): Unit

    Permalink
    Attributes
    protected[akka]
    Definition Classes
    Actor
    Annotations
    @InternalApi()
  10. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  11. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. def commandContext: BehaviorContext

    Permalink

    Returns the command BehaviorContext.

    Returns the command BehaviorContext.

    Definition Classes
    EventsourcedView
  13. implicit val context: ActorContext

    Permalink
    Definition Classes
    Actor
  14. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  16. def eventContext: BehaviorContext

    Permalink

    Returns the event BehaviorContext.

    Returns the event BehaviorContext.

    Definition Classes
    EventsourcedView
  17. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  19. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  20. val instanceId: Int

    Permalink
    Definition Classes
    EventsourcedView
  21. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  22. final def lastEmitterAggregateId: Option[String]

    Permalink

    Emitter aggregate id of the last handled event.

    Emitter aggregate id of the last handled event.

    Definition Classes
    EventsourcedView
  23. final def lastEmitterId: String

    Permalink

    Emitter id of the last handled event.

    Emitter id of the last handled event.

    Definition Classes
    EventsourcedView
  24. final def lastProcessId: String

    Permalink

    Id of the local event log that initially wrote the event.

    Id of the local event log that initially wrote the event.

    Definition Classes
    EventsourcedView
  25. final def lastSequenceNr: Long

    Permalink

    Sequence number of the last handled event.

    Sequence number of the last handled event.

    Definition Classes
    EventsourcedView
  26. final def lastSystemTimestamp: Long

    Permalink

    Wall-clock timestamp of the last handled event.

    Wall-clock timestamp of the last handled event.

    Definition Classes
    EventsourcedView
  27. final def lastVectorTimestamp: VectorTime

    Permalink

    Vector timestamp of the last handled event.

    Vector timestamp of the last handled event.

    Definition Classes
    EventsourcedView
  28. val logger: LoggingAdapter

    Permalink

    This actor's logging adapter.

    This actor's logging adapter.

    Definition Classes
    EventsourcedView
  29. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  30. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  31. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  32. def onRecovery: Handler[Unit]

    Permalink

    Recovery completion handler.

    Recovery completion handler. If called with a Failure, the actor will be stopped in any case, regardless of the action taken by the returned handler. The default handler implementation does nothing and can be overridden by implementations.

    Definition Classes
    EventsourcedView
  33. def onSnapshot: Receive

    Permalink

    Snapshot handler.

    Snapshot handler.

    Definition Classes
    EventsourcedView
  34. def postRestart(reason: Throwable): Unit

    Permalink
    Definition Classes
    Actor
    Annotations
    @throws( classOf[java.lang.Exception] )
  35. def postStop(): Unit

    Permalink

    Sets recovering to false before calling super.postStop.

    Sets recovering to false before calling super.postStop.

    Definition Classes
    EventsourcedView → UnrestrictedStash → Actor
  36. def preRestart(reason: Throwable, message: Option[Any]): Unit

    Permalink

    Sets recovering to false before calling super.preRestart.

    Sets recovering to false before calling super.preRestart.

    Definition Classes
    EventsourcedView → UnrestrictedStash → Actor
  37. def preStart(): Unit

    Permalink

    Initiates recovery.

    Initiates recovery.

    Definition Classes
    EventsourcedView → Actor
  38. def readFailure(cause: Throwable): Unit

    Permalink

    Called with failure details after a read operation failed.

    Called with failure details after a read operation failed. Throws EventsourcedWriter#ReadException by default (causing the writer to restart) and can be overridden.

    Definition Classes
    EventsourcedWriter → EventsourcedWriterFailureHandlers
  39. def readSuccess(result: R): Option[Long]

    Permalink

    Called with a read result after a read operation successfully completes.

    Called with a read result after a read operation successfully completes. This method may update internal actor state. If None is returned, the writer continues with state recovery by replaying events, optionally starting from a snapshot. If the return value is defined, replay starts from the returned sequence number without ever loading a snapshot. Does nothing and returns None by default and can be overridden.

    Definition Classes
    EventsourcedWriter → EventsourcedWriterSuccessHandlers
  40. final def receive: Receive

    Permalink

    Initialization behavior.

    Initialization behavior.

    Definition Classes
    EventsourcedView → Actor
  41. final def recovering: Boolean

    Permalink

    Returns true if this actor is currently recovering internal state by consuming replayed events from the event log.

    Returns true if this actor is currently recovering internal state by consuming replayed events from the event log. Returns false after recovery completed and the actor switches to consuming live events.

    Definition Classes
    EventsourcedView
  42. def replayBatchSize: Int

    Permalink

    Maximum number of events to be replayed to this actor before replaying is suspended.

    Maximum number of events to be replayed to this actor before replaying is suspended. A suspended replay is resumed automatically after all replayed events haven been handled by this actor's event handler (= backpressure). The default value for the maximum replay batch size is given by configuration item eventuate.log.replay-batch-size. Configured values can be overridden by overriding this method.

    Definition Classes
    EventsourcedView
  43. final def replayFromSequenceNr: Option[Long]

    Permalink

    Disallow for EventsourcedWriter and subclasses as event processing progress is determined by read and readSuccess.

    Disallow for EventsourcedWriter and subclasses as event processing progress is determined by read and readSuccess.

    Definition Classes
    EventsourcedWriterEventsourcedView
  44. final def save(snapshot: Any)(handler: Handler[SnapshotMetadata]): Unit

    Permalink

    Asynchronously saves the given snapshot and calls handler with the generated snapshot metadata.

    Asynchronously saves the given snapshot and calls handler with the generated snapshot metadata. The handler can obtain a reference to the initial message sender with sender().

    Definition Classes
    EventsourcedView
  45. implicit final val self: ActorRef

    Permalink
    Definition Classes
    Actor
  46. final def sender(): ActorRef

    Permalink
    Definition Classes
    Actor
  47. def snapshotContext: BehaviorContext

    Permalink

    Returns the snapshot BehaviorContext.

    Returns the snapshot BehaviorContext.

    Definition Classes
    EventsourcedView
  48. def stash(): Unit

    Permalink

    Adds the current command to the user's command stash.

    Adds the current command to the user's command stash. Must not be used in the event handler.

    Definition Classes
    EventsourcedView → StashSupport
  49. def supervisorStrategy: SupervisorStrategy

    Permalink
    Definition Classes
    Actor
  50. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  51. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  52. def unhandled(message: Any): Unit

    Permalink
    Definition Classes
    Actor
  53. def unstashAll(): Unit

    Permalink

    Prepends all stashed commands to the actor's mailbox and then clears the command stash.

    Prepends all stashed commands to the actor's mailbox and then clears the command stash. Has no effect if the actor is recovering i.e. if recovering returns true.

    Definition Classes
    EventsourcedView → StashSupport
  54. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  55. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  56. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  57. def writeFailure(cause: Throwable): Unit

    Permalink

    Called with failure details after a write operation failed.

    Called with failure details after a write operation failed. Throws EventsourcedWriter#WriteException by default (causing the writer to restart) and can be overridden.

    Definition Classes
    EventsourcedWriter → EventsourcedWriterFailureHandlers
  58. def writeSuccess(result: W): Unit

    Permalink

    Called with a write result after a write operation successfully completes.

    Called with a write result after a write operation successfully completes. This method may update internal actor state. Does nothing by default and can be overridden.

    Definition Classes
    EventsourcedWriter → EventsourcedWriterSuccessHandlers

Inherited from EventsourcedWriterFailureHandlers

Inherited from EventsourcedWriterSuccessHandlers[R, W]

Inherited from EventsourcedView

Inherited from Stash

Inherited from RequiresMessageQueue[DequeBasedMessageQueueSemantics]

Inherited from UnrestrictedStash

Inherited from StashSupport

Inherited from Actor

Inherited from AnyRef

Inherited from Any

Ungrouped