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
- On init, the sensor schedules an immediate tick (
{:schedule, 0}) - On each
:tickevent, it sends a message to the chat room - 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
@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.
@spec description() :: String.t() | nil
Returns the sensor's description.
@spec name() :: String.t()
Returns the sensor's name.
@spec schema() :: Zoi.schema() | nil
Returns the Zoi schema for sensor configuration.
@spec spec() :: Jido.Sensor.Spec.t()
Returns the sensor specification.
The spec contains all metadata needed to configure and run the sensor.