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

Toolkit Agent Design

Nstream provides the ability to add low-code agent functionality to a Swim server through the patch system.

Patches are pre-packaged agents that provide a wide range of functionality, such as HTTP polling, calculating rolling metrics or grouping agents. Most patches are wholly configuration driven but for more bespoke custom logic they can be extended and overridden. Functionality of nodes can be composed by combining multiple patches and agents.

When data is ingested into web agents they typically execute business logic by utilizing the ingested data and applying it to their current state. Typically, in SwimOS applications the business logic can be broken down into:

With SwimOS, developers may implement this business logic which is a non-trivial effort since developers have to address scalability and performance issues in addition to the core business logic. Nstream addresses these issues by providing a suite of configurable patches. These patches have been created based on our extensive experience building SwimOS applications. Developers can use these patches to empower their web agents with minimal effort.

Connectors

Connectors are a subset of patches that enable developers to connect to their data sources (e.g. Kafka, Pulsar, MySQL etc.), ingest data, route data/messages from these data sources to web agents and egress the state of web agents to these data sources. Each data source has a specific web agent which can be configured with that data source’s specific properties.

Dependencies

The dependencies required will depend on which patches are used, the page for each patch will detail which dependencies are required. All the io.nstream packages available can be found here.

For example, the nstream-adapter-runtime package contains the entry point for applications and so is commonly used:

Gradle

implementation 'io.nstream:nstream-adapter-runtime:'

Maven

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

Usage

To use a patch simply include the patch class name in the node definition in the server.recon file.

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

  @node {
    uri: "/vehicle/:id"
    @agent(class: "nstream.adapter.common.patches.LatestValuePatch")   # Add 'LatestValuePatch' to agent
  }
  
  ...
}

Configuration

Patches may require configuration, this can be included in a block in the agent definition:

# server.recon - Add 'groupUri' property to the 'MemberPatch'
  ...
  @node {
    uri: "/vehicle/:id"
    @agent(class: "nstream.adapter.common.patches.MemberPatch") {
        groupUri: "/country/US"     # Add 'groupUri' property to 'MemberPatch'
    }
  }
  ...

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