Agent Configuration

Examples Repo

Example configuration files showcasing all features we will discuss can be found in our Examples Repo .

Agent objects configure entities in the agent section of the configuration file. The agent section accepts a single agent object or an array of agent objects. Here is a list of available fields for agent objects:

Field Required Description
name true if uri is absent The name of the agent, used to create a URI and match to a relay.
uri true if name is absent Explicit URI pattern for the agent.
patches false Patches to compose agent behavior.

Only one of name or uri should be used in the agent section depending on the relay that references it. Use name if the relay uses the agent field to specify which agent should handle the received data, and use uri if the relay uses the node field to build a complex node URI for relaying data.

Adding Behavior to Entities with Patches

In Nstream-Jet, you can enhance the functionality and behavior of entities by applying patches to agents. Patches allow you to modify or extend the default behavior of agents, enabling customized processing, retention policies, and other advanced features. The patches field in the agent section of the configuration file is used to define these modifications, accepting either a single patch object or an array of patch objects.

The available patches are:

Type Description
latest Stores the most recent event.
history Stores a timestamp-keyed map of events.
group Collects entities with some common property into a group.
geopoint Extracts and stores geolocation data for map rendering.

If the patches field is omitted or empty, the agent will by default gain the latest and history patch.

The type field is the only required common field across all patches, other fields being specific to the patch and used to modify behavior. If no other fields are defined in the patch object (the patch has default behavior), the patch object can be reduced to just the type value.

"patches": [
  "latest",
  {
    "type": "history",
    "retentionCount": 10      
  }
]

Here we accept the default behavior of the latest patch and modify the history patch.

latest

The latest patch is the simplest patch available, storing each new message received in the latest lane.

The patch cannot be configured or modified and so no other fields are available.

history

The history patch will store each message received in the history map lane, keyed by timestamp.

The patch provides these fields for customization:

Field Default Behavior Description
retentionCount No limit Max size of the history map.
keyExtractor Receipt time Extract key/timestamp from message, if the message contains no timestamp then use receipt time.
valueExtractor Whole message Extract value from message.

group

The group patch will collect groups of agents with some common field and create separate group agents.

The patch provides these fields for customization:

Field Default Description
groupExtractor   Extract the group identifier from message.
groupUriPattern /group/:group The group URI pattern - only a single pattern part.

geopoint

The geopoint patch will extract geolocation data from messages and add agents to map tiles for map rendering.

The patch provides these fields for customization:

Field Default Description
longitude   The static longitude of the agent.
latitude   The static latitude of the agent.
longitudeExtractor $longitude Extract the longitude from a message.
latitudeExtractor $latitude Extract the latitude from a message.
valueExtractor   Extract the value from a message.

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