Packages

  • package root
    Definition Classes
    root
  • package com
    Definition Classes
    root
  • package cisco
    Definition Classes
    com
  • package streambed

    The base package of the Streambed library.

    The base package of the Streambed library. Of note is the com.cisco.streambed.Application suite of types. These types conveniently establish a streambed environment for an application.

    Sample usage from Java:

    /**
     * Bootstraps our application and handles signals
     */
    public class MyServerEntryPoints {
        private static ApplicationProcess applicationProcess = null;
    
        public static void main(String[] args) {
            applicationProcess = new ApplicationProcess(new MyServer());
            applicationProcess.main(args);
        }
    
        public static void trap(int signal) {
          if (applicationProcess != null) {
                applicationProcess.trap(signal);
            }
        }
    }

    ...with MyServer being declared as:

    public class MyServer extends Application {
        @Override
        public void main(String[] args, ApplicationContext context) {
          ..
        }
    }

    The equivalent in Scala:

    object MyServerEntryPoints {
      private lazy val applicationProcess = ApplicationProcess(MyServer)
    
      def main(args: Array[String]): Unit =
        applicationProcess.main(args)
    
      def trap(signal: Int): Unit =
        applicationProcess.trap(signal)
    }

    ...with MyServer being declared as:

    object MyServer extends Application {
      override def main(args: Array[String], applicationContext: ApplicationContext): Unit = {
        ..
      }
    }

    The essential idea is that a regular JVM entry point (MyServerEntryPoints), establishes a com.cisco.streambed.ApplicationProcess of a class named MyServer. The trap method is used by Landlord for whenever an operating systemm signal is sent to the process. My extending com.cisco.streambed.Application, a com.cisco.streambed.ApplicationContext is provided by Streambed, containing almost all of what an application will require in order to startup (an actor system, metrics, logging...). The resources provided within the context are also automatically released on exit.

    Definition Classes
    cisco
  • package storage

    Storage provides mechanisms to persist and retrieve arbitrary data.

    Storage provides mechanisms to persist and retrieve arbitrary data. This complements com.cisco.streambed.durablequeue.DurableQueue and can be used a snapshotting mechanism, a common pattern in event sourcing and CQRS systems.

    By default, an implementation using the local filesystem is provided. E.g. see "com.cisco.streambed.storage.fs.FileSystemRawStorage" elsewhere.

    Definition Classes
    streambed
  • package fs
    Definition Classes
    storage
  • package noop
    Definition Classes
    storage
  • RawStorage
  • Snapshots
  • StateCodec
  • Storage

object Snapshots

Types and functions for managing snapshots. Snapshots dramatically speed up the sourcing of events. The actual load/save mechanism is an outside concern to the domain of this module. This module is focused on how events can flow from and to storage and become aggregated.

A Snapshot's events are loaded and emitted as Snapshots.StoredEvent, followed by a Snapshots.StoredEventsDone on completion. New events are then sourced and emitted as Snapshots.StreamedEvents. A typical stream looks like:

Snapshots
  .fromStorage(storageLoader)
  .flatMapConcat(
    initialState =>
      tailFromOffset(initialState.offset, finite)
        .scan((initialState, Option.empty[DashboardsEvents.Event])) {
          case ((state, _), (element, offset)) =>
            val newState = nextState(state, element, offset)
            (newState, Some(element))
        }
        .drop(1)
        .wireTap(Snapshots.toStorage(storageSaver))
        .collect(Snapshots.streamedEvent)
        .prepend(Snapshots.storedEvents(source(initialState), None)))
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Snapshots
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. trait Aggregatable[A] extends AnyRef

    An Aggregatable is a structure for aggregated state that can have a iterable of elements along with some offset that they represent.

    An Aggregatable is a structure for aggregated state that can have a iterable of elements along with some offset that they represent. An offset is opaque to the snapshotting mechanism and can mean whatever it needs to mean to be able to source new events given a point in time.

    A

    The type of the elements to represent an aggregation of

  2. sealed trait SnapshotEvent[A] extends AnyRef

    An event that can be omitted by storage events.

    An event that can be omitted by storage events.

    A

    The type of the elements to represent

  3. final case class StoredEvent[A](element: A) extends SnapshotEvent[A] with Product with Serializable

    The event was sourced from storage.

    The event was sourced from storage.

    A

    The type of the elements to represent

  4. final case class StoredEventsDone[A, B](offset: Option[Long], context: Option[B]) extends SnapshotEvent[A] with Product with Serializable

    Signals that no more events are source from storage, along with an optional context value that can be used for any purpose.

    Signals that no more events are source from storage, along with an optional context value that can be used for any purpose.

    A

    The type of the elements to represent

    B

    The type of the context

  5. final case class StreamedEvent[A](element: A, offset: Option[Long]) extends SnapshotEvent[A] with Product with Serializable

    A regular streamed event i.e.

    A regular streamed event i.e. not loaded by storage.

    A

    The type of the elements to represent

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  9. def fromStorage[A <: Aggregatable[_]](storageLoader: Future[A]): Source[A, NotUsed]

    Source an Aggregatable value from storage.

    Source an Aggregatable value from storage.

    A

    The type of the Aggregatable

    storageLoader

    A source of having loaded the initial snapshot, which is an Aggregatable

    returns

    A source of the Aggregatable

  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. def storedEvents[A <: Aggregatable[B], B, Mat](elements: Source[B, Mat], offset: Option[Long], context: Option[_]): Source[SnapshotEvent[B], Mat]

    Source the elements of an Aggregatable that represent stored events and map them to StoredEvents followed by a StoredEventsDone on completion.

    Source the elements of an Aggregatable that represent stored events and map them to StoredEvents followed by a StoredEventsDone on completion.

    A

    The type of the Aggregatable

    B

    The type of the element of the Aggregatable

    elements

    the source elements to be emitted as StoredEvents

    offset

    An offset to emitted with each StoredEvent

    context

    some optional context to record in the StoredEventsDone element

  17. def streamedEvent[A <: Aggregatable[B], B]: PartialFunction[(A, Option[B]), StreamedEvent[B]]

    Partial function for testing an Aggregatable that has some associated element and, if so, maps it to a StreamedEvent.

    Partial function for testing an Aggregatable that has some associated element and, if so, maps it to a StreamedEvent. Useful in the context of a Stream's "collect" style of stage.

    A

    The type of the Aggregatable

    B

    The type of the element of the Aggregatable

    returns

    A StreamedEvent along with the current offset, if there is an element.

  18. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  19. def toStorage[A <: Aggregatable[_]](storageSaver: (A) => Future[Done]): Sink[Tuple2[A, _], Future[Done]]

    Save an Aggregatable to storage.

    Save an Aggregatable to storage.

    A

    The type of the Aggregatable

    storageSaver

    A function to perform the actual saving to storage

    returns

    A sink that performs the side-effecting saving to storage

  20. def toString(): String
    Definition Classes
    AnyRef → Any
  21. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  22. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  23. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped