March 7 - June 27, 2024 - Nstream is hitting the road with Confluent on the #DataInMotionTour! / Learn More

History Patch

Nstream provides a ‘History’ patch that greatly facilitates tracking previous agent state in a time series history lane. This guide demonstrates how to create and maintain a MapLane of events ordered by timestamp.

Dependencies

Gradle

implementation 'io.nstream:nstream-adapter-common:4.7.10'

Maven

<dependency>
  <groupId>io.nstream</groupId>
  <artifactId>nstream-adapter-common</artifactId>
  <version>4.7.10</version>
  <type>module</type>
</dependency>

Config

The HistoryPatch agent contains a MapLane named history that will store events by an extracted timestamp. In most cases, history lanes can be implemented wholly with configuration in the server.recon file. This involves adding HistoryPatch to the relevant nodes and setting some simple parameters. Simply define a node that includes the HistoryPatch agent:

# server.recon
...
space: @fabric {
  @plane(class:"nstream.adapter.runtime.AppPlane")

  # Domain Agents
  
  @node {
    pattern: "/vehicle/:id"
    @agent(class: "nstream.adapter.common.patches.HistoryPatch") {
        maxHistorySize: 10
        extractEpochMillisFromEvent: $timestamp
    }
  }

}

History Patch Config Options

Name Description Required Default Example
maxHistorySize Maximum number of records in history lane true Max Integer 10
extractEpochMillisFromEvent Value selector of timestamp false Current agent time $timestamp
extractValueFromEvent Value selector of event to store false Entire event $status

Nstream is licensed under the Redis Source Available License 2.0 (RSALv2).