Jido.Messaging.Demo.HeartbeatSensor (Jido Messaging v1.0.0)

Copy Markdown View Source

A Jido Sensor that emits periodic heartbeat messages to a chat room.

This sensor demonstrates Jido's sensor capability for scheduling periodic events. It fires every minute (60 seconds) and sends a thematic message from Agent Jido to the chat room.

Usage

Start the sensor with the messaging room context:

{:ok, _pid} = Jido.Sensor.Runtime.start_link(
  sensor: Jido.Messaging.Demo.HeartbeatSensor,
  config: %{
    interval: 60_000,
    room_id: "demo:lobby",
    instance_module: Jido.Messaging.Demo.Messaging
  }
)

How It Works

  1. On init, the sensor schedules an immediate tick ({:schedule, 0})
  2. On each :tick event, it sends a message to the chat room
  3. After sending, it schedules the next tick ({:schedule, interval})

The sensor uses the messaging system directly rather than emitting signals, since it's a standalone demo component that writes to the chat room.

Summary

Functions

Returns metadata for Jido.Discovery integration.

Returns the sensor's description.

Returns the sensor's name.

Returns the Zoi schema for sensor configuration.

Returns the sensor specification.

Functions

__sensor_metadata__()

@spec __sensor_metadata__() :: map()

Returns metadata for Jido.Discovery integration.

This function is used by Jido.Discovery to index sensors for fast lookup and filtering.

description()

@spec description() :: String.t() | nil

Returns the sensor's description.

name()

@spec name() :: String.t()

Returns the sensor's name.

schema()

@spec schema() :: Zoi.schema() | nil

Returns the Zoi schema for sensor configuration.

spec()

@spec spec() :: Jido.Sensor.Spec.t()

Returns the sensor specification.

The spec contains all metadata needed to configure and run the sensor.