object EventSource
Contains a function for applying a log type A to a state S, and persisting that state.
For example, the log entries may be Strings and the State 'S' could be Set[String]. Or perhaps the log entries are a sealed trait of CRUD operations, and the State is the database.
If the State itself is too big to fit in memory, then it could just be a cache over top a persistent storage.
If you don't want to persist the state and just e.g. event source from the beginning of the log, then this all becomes a lot easier (just a one-liner, folding A over the state S).
- Alphabetic
- By Inheritance
- EventSource
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
class
FileDao[S] extends StateDao[S]
A file-based StateDao implementation which writes a '.latestSnapshotIndex' file under the given directory to track what the last snapshot taken was
A file-based StateDao implementation which writes a '.latestSnapshotIndex' file under the given directory to track what the last snapshot taken was
It then writes down snapshot-X files to contain the persisted snapshots
- S
the snapshot type
-
trait
StateDao[S] extends AnyRef
Represents the IO needed to persist and retrieve a snapshot
Represents the IO needed to persist and retrieve a snapshot
- S
the snapshot type
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
-
def
apply[S, A](dao: StateDao[S], log: CommittedOps[A], snapEvery: Int, bufferSize: Int = 1000)(combine: (S, A) ⇒ S): Try[Observable[S]]
- S
the state type
- A
the log entry type
- dao
the access object for obtaining the snaphot
- log
a means of obtaining the 'committedEntriesFrom'
- snapEvery
the frequency of how often we should write down the snapshots
- combine
a function to combine the log entries of type 'A' w/ the state
- returns
an observable of the updated state
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- def dao[S, A](dataDir: Path, initial: ⇒ S, numberToKeep: Option[Int] = None)(implicit arg0: FromBytes[S], arg1: ToBytes[S]): FileDao[S]
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
inDir[S, A](dataDir: Path, initial: ⇒ S, log: CommittedOps[A], snapEvery: Int, numberToKeep: Option[Int] = None)(combine: (S, A) ⇒ S)(implicit arg0: FromBytes[S], arg1: ToBytes[S]): Try[Observable[S]]
Provides a means to track snapshots for the log.
Provides a means to track snapshots for the log. Instead of observing the log directly, the EventSource observes the log and ever N updates produces a snapshot.
This is typically more useful than observing the logs directly, as it provides a way to represent your application's state machine (of type 'S') by applying single log entries to it (of type 'A').
Observers of the snapshot will get the latest snapshot version and the raw log entries ;-)
This is an alternative to log compaction.
- S
the snapshot type
- A
the log entry type
- dataDir
the directory under which snapshots should be written
- initial
the initial state should none be available
- log
a means of obtaining the 'committedEntriesFrom'
- snapEvery
the frequency of how often we should write down the snapshots
- combine
a function to combine the log entries of type 'A' w/ the state
-
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
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )